• Resolved jessamca11

    (@jessamca11)


    Hello,

    I used Code Snippets to successfully add the following code to have CAD after my prices.

    add_filter( 'woocommerce_get_price_html', 'bbloomer_add_price_prefix', 99, 2 );
      
    function bbloomer_add_price_prefix( $price, $product ){
        $price = 'Prefix here ' . $price;
        return $price;
    }

    However, it doesnt add the suffix to my cart or checkout page.

    Is there a way to make this possible as well?

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @jessamca11!

    Try the following:

    function rs_custom_currency_symbols( $currency_symbol, $currency ) {
        switch( $currency ) {
            case 'CAD':
                $currency_symbol = '$ CAD ';
        }
        return $currency_symbol;
    }
    add_filter('woocommerce_currency_symbol', 'rs_custom_currency_symbols', 30, 2);

    Cheers!

    Thread Starter jessamca11

    (@jessamca11)

    thank you! this works great.

    however it says $ CAD 22

    How would I make it say $22 CAD instead?

    thanks

    Plugin Support abwaita a11n

    (@abwaita)

    Hi @jessamca11,

    Thanks for getting back.

    Another approach would be to add CAD after the price using CSS. You could try adding this to your Customizer → Additional CSS box:

    bdi:after {
        content: " CAD";
    }

    Thanks.

    Plugin Support abwaita a11n

    (@abwaita)

    Hi,
    We’ve not heard back from you in a while, so I’m marking this thread as resolved.

    Just to mention, you could adapt your earlier solution further to show CAD price suffix on your cart and checkout pages by also targeting the following:

    * woocommerce_cart_item_price
    * woocommerce_cart_item_subtotal
    * woocommerce_cart_subtotal
    * woocommerce_cart_total

    So, something like this should work:

    add_filter( 'woocommerce_get_price_html', 'bbloomer_add_price_prefix', 99, 2 );
    
    add_filter( 'woocommerce_cart_item_price', 'bbloomer_add_price_prefix' );
    add_filter( 'woocommerce_cart_item_subtotal', 'bbloomer_add_price_prefix' );  
    add_filter( 'woocommerce_cart_subtotal', 'bbloomer_add_price_prefix' );  
    add_filter( 'woocommerce_cart_total', 'bbloomer_add_price_prefix' );
      
    function bbloomer_add_price_prefix( $price, $product ){
        $price = 'CAD' . $price;
        return $price;
    }

    Hopefully, all the above suggestions were helpful!

    If you have further questions, please feel free to open a new topic.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘adding currency beside price’ is closed to new replies.