Advertisement
businessdad

WooCommerce Extended Coupon Features - Convert thresholds

Jan 22nd, 2020
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. /**
  2.  * WooCommerce Extended Coupon Features
  3.  * The following example shows how to convert the minimum and maximum matching products subtotals
  4.  * assigned to a coupon by using the filters provided by the Aelia Currency Switcher.
  5.  *
  6.  * DISCLAIMER
  7.  * Aelia and any member of its staff are not responsible for any data loss or damage incurred
  8.  * when using the code, which you can use at your own risk.
  9.  *
  10.  * GPL DISCLAIMER
  11.  * Because this code program is free of charge, there is no warranty for it, to the extent permitted by applicable law.
  12.  * Except when otherwise stated in writing the copyright holders and/or other parties provide the program "as is"
  13.  * without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of
  14.  * merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program
  15.  * is with you. should the program prove defective, you assume the cost of all necessary servicing, repair or correction.
  16.  *
  17.  * Need a consultation, or assistance to customise this code? Find us on Codeable: https://aelia.co/hire_us
  18.  */
  19.  
  20. function convert_amount_from_base_currency($amount, $to_currency) {
  21.   if(is_numeric($amount)) {a
  22.     $amount = apply_filters('wc_aelia_cs_convert', $amount, get_option('woocommerce_currency'), $to_currency);
  23.   }
  24.   return $amount;
  25. }
  26.  
  27. add_filter('woocommerce_coupon_get__wjecf_min_matching_product_subtotal', function($value, $coupon) {
  28.   $value = convert_amount_from_base_currency($value, get_woocommerce_currency());
  29.   return $value;
  30. }, 10, 2);
  31.  
  32. add_filter('woocommerce_coupon_get__wjecf_max_matching_product_subtotal', function($value, $coupon) {
  33.   $value = convert_amount_from_base_currency($value, get_woocommerce_currency());
  34.   return $value;
  35. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement