Using Sitewide Sales in your WooCommerce site? If you’re also using the RightPress plugins for live price updates, this recipe is for you.
This tutorial ensures seamless integration of Sitewide Sales discounts with RightPress’ Live Product Price Updates, enhancing the shopping experience by instantly reflecting sale prices.
How It Works
The code hooks into the RightPress live price update flow. It detects an active Sitewide Sales campaign and applies the corresponding discount to the product’s live price, if applicable.
This dynamic pricing update occurs site-wide, ensuring that all eligible products display the discounted rate in real time.
This PHP function taps into the
rightpress_product_price_live_update_price filter, adjusting the product price if a sale is active. It creates an instance of the current sale, validates the associated coupon, and applies the discount directly to the live price output.
There are two options in this recipe:
- Use the version on line 30 if you want to base the live update price on the product’s original price in WooCommerce.
- Use the version on line 34 if you want to base the discount on the updated live price.
Adding the Recipe to Your Website
You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. We have a post on how to create a customizations plugin on our partner website, Paid Memberships Pro.
Remember to test the functionality in a staging environment before pushing it live to avoid disrupting your sales process. With this recipe, your live product prices reflect active discounts instantly, elevating user engagement and driving sales.