businessdad

Cache Handler - Prevent the Subscriptions plugin from showing a duplicate suffix

Aug 30th, 2022
2,285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. /**
  2.  * Removes the price suffix appended to the product prices by the Subscriptions plugin, when
  3.  * the Cache Handler is fetching the updated prices via Ajax. This prevents the issue of having
  4.  * a duplicate price suffix displayed on the page.
  5.  */
  6. add_filter('woocommerce_subscriptions_product_price_string', function($subscriptions_product_price_string) {
  7.     // If we're processing the "fetch prices" call from the Cache Handler, remove the price suffix that
  8.     // the Subscriptions plugin forcibly appends to the HTML that shows the price, so that it won't be
  9.     // displayed twice
  10.     if(defined('DOING_AJAX') && (($_REQUEST['action'] ?? '') === 'woocommerce_cache_handler_ajax') && ($_REQUEST['exec'] === 'get_product_prices_html')) {
  11.         $subscriptions_product_price_string = '';
  12.     }
  13.  
  14.     return $subscriptions_product_price_string;
  15. }, 99);
Advertisement
Add Comment
Please, Sign In to add comment