Price suffix

Closed
REHub - Price Comparison, Affiliate Marketing, Multi Vendor Store, Community Theme REHub - Price Comparison, Affiliate Marketing, Multi Vendor Store, Community Theme June 21, 2020
Login to reply
Ahmed sleiman
3 years ago

sorry my bad, the issue was in the product.

the code is working perfectly fine

Igor Sunz Support Agent
3 years ago

ok. where you added this code? And how do you set price in product?

Ahmed sleiman
3 years ago

dear, 

I tried several values like

1,2
1000,2

and others but nothing worked.
weird is that '/month' is appearing.


I also tried the following code: and it didn't work


https://gist.github.com/iMazed/60b41dc6dc3713483853590013e5d0f5

Igor Sunz Support Agent
3 years ago

add_filter( 'woocommerce_get_price_html', 'conditional_price_suffix', 1000, 3 );

here, replace 3 to 2

Ahmed sleiman
3 years ago

Dear Team,

I've entered the following php code so that I add a custom suffix/prefix to the price.

the issue is that the custom message appear, but the price is not appearing. any advise?


link to the issue: https://www.qarenha.com/product-category/tele/

add_filter( 'woocommerce_get_price_html', 'conditional_price_suffix', 1000, 3 );
function conditional_price_suffix( $price, $product ) {
   
    $product_categories = array('tele','hoodies');
    if( has_term( $product_categories, 'product_cat', $product->get_id() ) )
        $price = $price . __('/ month');
    return $price;
}