Advertisement
businessdad

WooCommerce Currency Switcher - Append USD prices

Jan 15th, 2018
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.62 KB | None | 0 0
  1. /**
  2.  * Aelia Currency Switcher for WooCommerce - Show USD price next each product price.
  3.  *
  4.  * HOW TO USE THIS CODE
  5.  * Add the code to the bottom of your theme's functions.php file (see https://www.skyverge.com/blog/add-custom-code-to-wordpress/).
  6.  * The code will automatically append the USD price to every product price.
  7.  *
  8.  * NOTES
  9.  * The code is a proof of concept, and doesn't include a refined logic to handle variable products, but it can
  10.  * be extended for this purpose, and to handle custom product types. Should you need asssistance with this, you
  11.  * can find our contacts below.
  12.  *
  13.  * GPL DISCLAIMER
  14.  * Because this code program is free of charge, there is no warranty for it, to the extent permitted by applicable law.
  15.  * Except when otherwise stated in writing the copyright holders and/or other parties provide the program "as is"
  16.  * without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of
  17.  * merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program
  18.  * is with you. should the program prove defective, you assume the cost of all necessary servicing, repair or correction.
  19.  *
  20.  * Need a consultation, or assistance to customise this code? Find us on Codeable: https://aelia.co/hire_us
  21.  */
  22. add_filter('woocommerce_get_price_html', function($price, $product) {
  23.   // Call the Currency Switcher shortcode to render the product price in USD
  24.   $price .= ' (' . do_shortcode('[aelia_cs_product_price product_id="' . $product->get_id() . '" formatted="1" currency="USD"]') . ')';
  25.   return $price;
  26. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement