Select Page

Different text after price, on selected products – NOT working on variation prod

Home Forums Support Different text after price, on selected products – NOT working on variation prod

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • Helpful
    Up
    0
    Down
    Not Helpful

    Greetings,
    I found an awesome code that gives you the posibility to have different text after the prices only on the products that you chose.
    Unfortunately, it doesțt work on Variable products for some reason. I guess it because the span class or something:
    The code works for normal products, but for variable products it just doesnt want to work.
    Any ideea on how to fix this, please?

    //Add in text after price to certain products
    function themeprefix_custom_price_message( $price ) {

    global $post;

    $product_id = $post->ID;
    $my_product_array = array(1001,1002);// add the ID of the product 1001,1002 etc
    if ( in_array( $product_id, $my_product_array )) {
    $textafter = ‘( Write your text )’; //add your text
    return $price . ‘<br /><span class=”bc-price-after”>’ . $textafter . ‘</span>’;
    }

    else {
    return $price;
    }
    }
    add_filter( ‘woocommerce_get_price_html’, ‘themeprefix_custom_price_message’ );

    Thanks!

    Helpful
    Up
    0
    Down
    Not Helpful

    Hi,

    I am not entirely sure without doing some research because the variation price changes based on what you select. This code will add the price and after text at start.

    You can do this with our “PL Price” module – there is a setting to add text after the price

    Helpful
    Up
    0
    Down
    Not Helpful

    Hi,
    Thanks for your reply. Yes, you can add “text after price”, but it will be the same price for all products.
    So the script adds the text, only on the products you chose ( after id).
    For example, Apple Price 1 Euro /Per Kg and Strawberry 1 Euro / Case

    So, the problem is… whats the problem with the Variable Products on Body Commerce… On normal products it works fine.

    Helpful
    Up
    0
    Down
    Not Helpful

    Srry,
    “Thanks for your reply. Yes, you can add “text after price”, but it will be the same TEXT for all products.”

    Helpful
    Up
    0
    Down
    Not Helpful

    TO confirm, this is a variation issue and not BodyCommerce related? If you disable BodyCommerce it work the same as when active?

    Helpful
    Up
    0
    Down
    Not Helpful

    I’m afraid it is BodyCommerce related. If I dezactivate BodyCommerce, the text will appear after the price for variable products.
    If I enable it, the text after the price disapears.
    Something from BodyCommerce is blocking the script to show the text ONLY on variable products.
    I assume some css class is missing or something…

    //THIS class it’s not showing on variable products with BodyCommerce” //
    <span class=”woocommerce-Price-amount amount”>5,50 <span class=”woocommerce-Price-currencySymbol”>lei</span></span>
    //End//
    //This info is displayed on variable and normal products – the difference is that on variable it doesnt inject the “EUR” added text”
    <span class=”bodycommerce-changes-variation-price .bc-price-after”>( EUR )</span>

    EUR is the text I added manualy with the Script, and thats how it’s injected.

    Thanka again for checking it.

    Helpful
    Up
    0
    Down
    Not Helpful

    I did a test on my dev site and it works – please email @diviengine.com">support@diviengine.com with a link to your site and if you can admin logins so I can provide more support this way.

    To confirm, this code works on variation products

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.