Code Recipes Archives - Sitewide Sales: All-in-One Flash Sales Plugin for WordPress https://sitewidesales.com/category/code-recipes/ Fri, 05 Jan 2024 18:52:19 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.4 https://sitewidesales.com/wp-content/uploads/2019/10/cropped-Sitewide-Sales_favicon-32x32.gif Code Recipes Archives - Sitewide Sales: All-in-One Flash Sales Plugin for WordPress https://sitewidesales.com/category/code-recipes/ 32 32 Sitewide Sales and WooCommerce Compatibility for RightPress Product Price Live Update https://sitewidesales.com/woocommerce-compatibility-for-rightpress-product-price-live-update/ Sun, 19 Nov 2023 12:31:18 +0000 https://sitewidesales.com/?p=11063 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 […]

The post Sitewide Sales and WooCommerce Compatibility for RightPress Product Price Live Update appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
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.

WooCommerce Compatibility for RightPress Product Price Live Update

Table of contents

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.

Single Product page with strikethrough pricing and a live update price that reflects the sitewide discount

Code Recipe

View the code on Gist.

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.

The post Sitewide Sales and WooCommerce Compatibility for RightPress Product Price Live Update appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
Hide Sale Banners for Previous Customers in Easy Digital Downloads https://sitewidesales.com/hide-sale-banners-previous-customers-easy-digital-downloads/ Thu, 23 Jun 2022 14:12:56 +0000 https://sitewidesales.com/?p=10047 Offering new customers a unique incentive is a strong way to convert new shoppers. But how do you prevent these discount banners from being shown to your existing, previous customers? In this code tutorial, I show you two methods to hide your Sitewide Sale banner for previous customers in EDD. First, there is code to […]

The post Hide Sale Banners for Previous Customers in Easy Digital Downloads appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
Offering new customers a unique incentive is a strong way to convert new shoppers. But how do you prevent these discount banners from being shown to your existing, previous customers?

In this code tutorial, I show you two methods to hide your Sitewide Sale banner for previous customers in EDD. First, there is code to check for a specific purchase, by download ID, for the current logged in user. The second section is a general check whether the current user has made any purchases at all through EDD.

Hide Sale Banners for Previous Customers in Easy Digital Downloads

The Code Recipe

View the code on Gist.

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.

Modify line 15 for your specific download IDs. If you need to check for more than one product ID, you can duplicate lines 14-17 and set a unique product ID for each check. The function edd_has_user_purchased does not accept an array of IDs. Or, remove lines 14-17 if you only want to use the general check for any previous purchases.

The post Hide Sale Banners for Previous Customers in Easy Digital Downloads appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
Hide Discount Code Field in Easy Digital Downloads https://sitewidesales.com/hide-discount-code-field-easy-digital-downloads/ Thu, 23 Jun 2022 12:18:16 +0000 https://sitewidesales.com/?p=10031 Coupons are a great way to convert those “on the fence” shoppers. But research has shown that the presence of a “discount code” field on your checkout page can slow buyers down and (sometimes) lose you money. In this tutorial, I give you the code to hide the discount code field in Easy Digital Downloads. […]

The post Hide Discount Code Field in Easy Digital Downloads appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
Coupons are a great way to convert those “on the fence” shoppers. But research has shown that the presence of a “discount code” field on your checkout page can slow buyers down and (sometimes) lose you money.

In this tutorial, I give you the code to hide the discount code field in Easy Digital Downloads. I’ve included a few example URLs that allow you to pass in a code via URL so that your site can still run a promotional offer.

Hide Discount Code Field in Easy Digital Downloads

Include Discount Code in URL

Easy Digital Downloads supports adding a discount code to the cart via URL. Here are two example URLs that show you how to pass a discount code through to the checkout page via URL attribute:

Direct URL to the cart page with the coupon code ‘loyal’.

http://sitewidesales.local/checkout/?discount=loyal

Add a specific download (by ID) to the checkout and automatically apply the coupon code ‘loyal’. This is a great way to drive checkout conversions for a single product on sale.

http://sitewidesales.local/checkout/?edd_action=add_to_cart&download_id=319&discount=loyal

The Code Recipe

View the code on Gist.

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.

Before and After Screenshots

Easy Digital Downloads Cart Screenshot with a Visible Coupon Code Field
Easy Digital Downloads Cart Screenshot with a Visible Coupon Code Field
Easy Digital Downloads Cart Screenshot with No Coupon Code Field
Easy Digital Downloads Cart Screenshot with No Coupon Code Field

Run a Better Sale with Easy Digital Downloads

Sitewide Sales is a new way to run sales for your WordPress-powered ecommerce site. Using Sitewide Sales, you can set up an active promotion that runs from your set start time and end time.

The plugin automatically applies discounts according to the rules you set up—no coding required. If you want to run a true sale that automatically applies a discount without the need for manual coupon entry, you need try the Sitewide Sales plugin—it works with Easy Digital Downloads and other popular ecommerce plugins for WordPress.

The post Hide Discount Code Field in Easy Digital Downloads appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
Apply a WooCommerce Coupon Code to the Cart Via URL https://sitewidesales.com/apply-woocommerce-coupon-code-via-url/ Thu, 23 Jun 2022 11:46:01 +0000 https://sitewidesales.com/?p=10018 This code recipe sets up a direct link to your WooCommerce cart page that automatically applies the coupon code. Now you can offer a more foolproof shopping experience and show buyers the exact discount for their active cart. Use this recipe in combination with our tutorial to hide the Coupon Code field in WooCommerce for […]

The post Apply a WooCommerce Coupon Code to the Cart Via URL appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
This code recipe sets up a direct link to your WooCommerce cart page that automatically applies the coupon code. Now you can offer a more foolproof shopping experience and show buyers the exact discount for their active cart.

Use this recipe in combination with our tutorial to hide the Coupon Code field in WooCommerce for an even tighter, more controlled shopping experience.

Apply a WooCommerce Coupon Code to the Cart Via URL

How to Share Coupon Codes in the URL

Below are three example URLs for your store that pass the discount or coupon code and automatically apply the code on the customer’s cart.

Direct URL to the cart page with the coupon code ‘loyal’.

http://sitewidesales.local/cart/?coupon=loyal

Add a specific product (by ID) to the cart and automatically apply the coupon code ‘loyal’. This is a great way to drive checkout conversions for a single product on sale.

http://sitewidesales.local/cart/?add-to-cart=21&coupon=loyal

Direct users right to the checkout page with a specific product (by ID) added to their cart and automatically applied coupon code ‘loyal’.

http://sitewidesales.local/checkout/?add-to-cart=21&coupon=loyal

The Code Recipe

View the code on Gist.

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.

Automatic Coupon Applied via Sitewide Sales

Sitewide Sales is a new way to run sales for your WordPress-powered ecommerce site. Using Sitewide Sales, you can set up an active promotion that runs from your set start time and end time.

The plugin automatically applies discounts according to the rules you set up—no coding required. If you want to run a true sale that automatically applies a discount without the need for manual coupon entry, you need try the Sitewide Sales plugin—it works with WooCommerce and other popular ecommerce plugins for WordPress.

The post Apply a WooCommerce Coupon Code to the Cart Via URL appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
Hide Coupon Code Field in WooCommerce https://sitewidesales.com/hide-coupon-code-field-in-woocommerce/ Thu, 23 Jun 2022 11:25:08 +0000 https://sitewidesales.com/?p=10010 WooCommerce has a global setting to disable the use of coupons. Some sites would rather hide the field and allow users to add coupon codes via other methods, such as a URL attribute. This code recipe disables the “Coupon Code” field shown on the WooCommerce cart page. The Code Recipe View the code on Gist. […]

The post Hide Coupon Code Field in WooCommerce appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
WooCommerce has a global setting to disable the use of coupons. Some sites would rather hide the field and allow users to add coupon codes via other methods, such as a URL attribute. This code recipe disables the “Coupon Code” field shown on the WooCommerce cart page.

Hide Coupon Code Field on WooCommerce Checkout Page

The Code Recipe

View the code on Gist.

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.

Before and After Screenshots

WooCommerce Cart Screenshot with a Visible Coupon Code Field
WooCommerce Cart Screenshot with a Visible Coupon Code Field
WooCommerce Cart Screenshot with No Coupon Code Field
WooCommerce Cart Screenshot with No Coupon Code Field

Run a Better Sale with WooComerce

Sitewide Sales is a new way to run sales for your WordPress-powered ecommerce site. Using Sitewide Sales, you can set up an active promotion that runs from your set start time and end time.

The plugin automatically applies discounts according to the rules you set up—no coding required. If you want to run a true sale that automatically applies a discount without the need for manual coupon entry, you need try the Sitewide Sales plugin—it works with WooCommerce and other popular ecommerce plugins for WordPress.

The post Hide Coupon Code Field in WooCommerce appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
Add a Countdown Timer to WooCommerce Store Notice https://sitewidesales.com/woocommerce-store-notice-countdown-timer/ Wed, 22 Jun 2022 21:40:45 +0000 https://sitewidesales.com/?p=9831 Countdown timers are a visual way to create urgency and motivate purchases when running a sale on your ecommerce site. This blog post shows you step-by-step instructions to add a simple store notice with a WooCommerce countdown timer. Required Plugins Used In This Guide For this tutorial, I’m using a basic WordPress site with the […]

The post Add a Countdown Timer to WooCommerce Store Notice appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
Countdown timers are a visual way to create urgency and motivate purchases when running a sale on your ecommerce site. This blog post shows you step-by-step instructions to add a simple store notice with a WooCommerce countdown timer.

How to Add a Countdown Timer to WooCommerce Store Notice

Required Plugins Used In This Guide

For this tutorial, I’m using a basic WordPress site with the following theme and plugins:

  • WooCommerce: a WordPress ecommerce plugin
  • Blocksy: a WooCommerce compatible theme by Creative Themes
  • HurryTimer: a countdown timer plugin
  • Code Snippets: a plugin that adds PHP code recipes right in the WordPress admin.

There are loads of countdown timer plugins available for free in the WordPress.org plugin repository. I chose HurryTimer because it’s the plugin we use at Paid Memberships Pro when running our own sitewide sales.

On to the tutorial!

How To Add a WooCommerce Countdown Timer Store Notice

Time needed: 30 minutes

This tutorial is a step-by-step walkthrough on how to create a new countdown timer in WordPress that displays in a sitewide banner or “Store Notice” in WooCommerce.

  1. In your WordPress admin, navigate to HurryTimer > Add Campaign.

    Enter a name to identify your timer. The name is only shown to you as the admin and helps you identify what this timer is for.Hurrytimer Admin Post Type > Add New Campaign

  2. Configure your timer’s end date and display settings.

    Set up a basic timer with a specific end date. After you configure other timer settings, click to save and publish the timer. Once your timer is published, HurryTimer displays a unique shortcode that you will need for a later step.
    Edit HurryTimer New Campaign

  3. In the WordPress admin, navigate to Snippets > Add New.

    Copy and paste the exact code from my example recipe at the bottom of this post. This code will load the content of your Store Notice and make sure that any shortcodes render on the frontend of your site.

    Once the code is added, click the button to “Save and Activate” the snippet. Phew. I knew you were a coder.Code Snippet Screenshot to Allow Shortcode in WooCommerce Store Notice

  4. Next, navigate to Appearance > Customize in the WordPress admin. This action opens the Theme Customizer feature of WordPress.

    Scroll to the bottom of the left column menu and choose WooCommerce. Then select “Store Notice”.Turn on WooCommerce Store Notice in WordPress Customizer

  5. Now you’re ready to set up the actual banner that will show on your WooCommerce site.

    First, check the box to “Enable store notice”. You’ll need this setting activated so you can preview the appearance of your notice.

  6. In the empty textarea, add some information about your sale and paste the shortcode from HurryTimer.

    Your store notice may look different depending on the WooCommerce theme used in your WordPress site. I’m using Blocksy by Creative Themes which has support for WooCommerce.

    If you aren’t ready to launch the banner on your store, uncheck the “Enable store notice” setting before you hit publish. I put a link in the video description with some tutorials on how to turn on the notice at a specific date and time. Or, you can come back and manually enable it when your sale begins.

    When you’re happy with your notice text, click “Publish” to update your site.Edit Store Notice in WordPress Customizer

  7. Go check out your site and countdown timer!

    You can now navigate to view your live site. You should see the store notice with the active countdown timer ticking away.

    If you want to make this a little prettier, I also included a few lines of copy and paste CSS that you can use to make your site look like this tutorial.Screenshot of the site with WooCommerce Store Notice and Countdown Timer

The Code Recipe

View the code on Gist.

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.

The Custom CSS

.woocommerce-store-notice .hurrytimer-campaign {
	margin-left: 20px;
}
.woocommerce-store-notice .hurrytimer-timer-block {
	background: rgba( 255, 255, 255, 0.1);
	padding: 5px 15px;
}
.demo_store a.woocommerce-store-notice__dismiss-link {
	background: none;
}

Add the Custom CSS To Your Site

  • If you’re already using a child theme, this CSS can be added directly to your child theme’s style.css file.
  • Or, navigate to Appearance > Customize.
  • In the Theme Customizer, locate the “Additional CSS” field.
  • Paste this CSS into the field.
  • Click “Publish” to push these changes to your live site.

Build Better Banner Ads with the Sitewide Sales Plugin for WooCommerce

This recipe shows a simple way to adjust your WooCommerce Store Notice and add a countdown timer. If you want to run a true sale that automatically starts and stops based on your start and end date, you need try the Sitewide Sales plugin—it works with WooCommerce and other popular ecommerce plugins for WordPress.

The post Add a Countdown Timer to WooCommerce Store Notice appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
Turn Off the WooCommerce Store Notice On Specific Date and Time https://sitewidesales.com/turn-off-woocommerce-store-notice-specific-date-and-time/ Mon, 13 Jun 2022 12:00:00 +0000 https://sitewidesales.com/?p=9810 WooCommerce Store Notices allow you to set a “start date” for when the banner should appear on your site. But how do you automatically turn that notification bar off? This tooltip gives you custom code to hide the “Store Notice” at a specific end date and time. Use this method as a simple way to […]

The post Turn Off the WooCommerce Store Notice On Specific Date and Time appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
WooCommerce Store Notices allow you to set a “start date” for when the banner should appear on your site. But how do you automatically turn that notification bar off?

This tooltip gives you custom code to hide the “Store Notice” at a specific end date and time. Use this method as a simple way to run a “Flash Sale” with access to limited time deals.

Turn off the Store Notice in WooCommerce at a Specific Date and Time

The Code Recipe

View the code on Gist.

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.

Modify line 10 of the code recipe for your specific banner end date and time in the format: Y-m-d H:i:s (i.e. 2022-06-08 10:00:00).

Leverage The sitewide sales Plugin For More Features

This recipe shows a simple way to hide the WooCommerce Store Notice. If you need more robust sitewide sale banners and notification bars, try the Sitewide Sales plugin—it works with WooCommerce and other popular ecommerce plugins for WordPress.

The post Turn Off the WooCommerce Store Notice On Specific Date and Time appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
Show WooCommerce Store Notice for Existing Customers Only https://sitewidesales.com/show-woocommerce-store-notice-existing-customers-only/ Fri, 10 Jun 2022 15:38:00 +0000 https://sitewidesales.com/?p=9805 WooCommerce includes a basic “Store Notice” so shops can show a notification banner to site visitors. In this tooltip, we should you a few lines of custom code to only show the notice to existing customers. Use this method as a simple way to give “Repeat Customers” access to special deals. The Code Recipe View […]

The post Show WooCommerce Store Notice for Existing Customers Only appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
WooCommerce includes a basic “Store Notice” so shops can show a notification banner to site visitors. In this tooltip, we should you a few lines of custom code to only show the notice to existing customers. Use this method as a simple way to give “Repeat Customers” access to special deals.

Show WooCommerce Store Notice for Customers Only

The Code Recipe

View the code on Gist.

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.

Screenshots

Below are screenshots of the demo site with the code recipe active. This demonstrates how the Store Notice is shown for logged in customers only (for any user that has the customer role) and hidden for everyone else.

WooCommerce Demo Site Screenshot For Customers (Store Notice Visible)
WooCommerce Demo Site Screenshot For Customers (Store Notice Visible)
WooCommerce Demo Site Screenshot For Non Customers (No Store Notice)
WooCommerce Demo Site Screenshot For Non Customers (No Store Notice)

Leverage The sitewide sales Plugin For More Features

This recipe shows a simple way to hide the WooCommerce Store Notice. If you need more robust sitewide sale banners and notification bars, try the Sitewide Sales plugin—it works with WooCommerce and other popular ecommerce plugins for WordPress.

The post Show WooCommerce Store Notice for Existing Customers Only appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
Show WooCommerce Store Notice for Visitors Only https://sitewidesales.com/woocommerce-store-notice-visitors-only/ Wed, 08 Jun 2022 15:35:04 +0000 https://sitewidesales.com/?p=9788 Store notices in WooCommerce are a great way to show a lightweight banner in your ecommerce store. This tooltip gives you custom code to hide the “Store Notice” for all logged in users. Use this method as a simple way to give “New Customers” access to special deals. The Code Recipe View the code on […]

The post Show WooCommerce Store Notice for Visitors Only appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>
Store notices in WooCommerce are a great way to show a lightweight banner in your ecommerce store. This tooltip gives you custom code to hide the “Store Notice” for all logged in users. Use this method as a simple way to give “New Customers” access to special deals.

Show WooCommerce Store Notice for Visitors Only

The Code Recipe

View the code on Gist.

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.

Screenshots

Below are screenshots of the demo site with the code recipe active. This demonstrates how the Store Notice is shown for non-users (for any visitor that is not logged into the site) and hidden when the user is logged in.

WooCommerce Demo Site Screenshot For Logged In User (No Store Notice)
WooCommerce Demo Site Screenshot For Logged In User (No Store Notice)
WooCommerce Demo Site Screenshot For Visitor (Store Notice Visible)
WooCommerce Demo Site Screenshot For Visitor (Store Notice Visible)

Leverage The sitewide sales Plugin For More Features

This recipe shows a simple way to hide the WooCommerce Store Notice. If you need more robust sitewide sale banners and notification bars, try the Sitewide Sales plugin—it works with WooCommerce and other popular ecommerce plugins for WordPress.

The post Show WooCommerce Store Notice for Visitors Only appeared first on Sitewide Sales: All-in-One Flash Sales Plugin for WordPress.

]]>