• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2966

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Checkout
  • Log in

Restrict products by billing email addresses at checkout – WooCommerce

Restrict products by billing email addresses at checkout in WooCommerce

$75.00

Demo Video
Category: WooCommerce Tags: array_intersect, array_map, array_merge, get_cart_contents_count, get_option, woocommerce_after_checkout_validation, woocommerce_get_settings_email
  • Description

This PHP code for WooCommerce users enables the storeowner to restrict the sale of specific products to a customers billing email address.

The code includes :

  • A text field added to the WooCommerce > Settings page to added a comma separated list of product ids you want restricted.
  • A custom input field added to the WooCommerce > Settings page for pasting comma separated billing email addresses.
  • A function for adding an error notice on the checkout page when the customers billing email addresses doesn’t match the comma separated list.
  • A function to match product ids in cart at checkout against restricted product ids so error messages are only displayed for restricted products.
  • A function which counts the number of matched product ids and changes the product text to products ( plural ) if more than 1 restricted product has been added to the cart.
  • Code to prevent the order being placed when the customers billing email doesn’t match your list.

Custom error message on WooCommerce checkout page restricting purchase of products by billing email addresses

Configuration

In your WordPress Dashboard, go to WooCommerce > Settings > Restricted Emails and add your comma separated list of product ids and billing email addresses for your customers.

Custom text field and text area added to custom WooCommerce Settings page

Installation

Copy & paste the PHP code to the end of your child themes functions file or custom functionality plugin.

Or

Install the zip folder as a new plugin and the configure the settings as seen in the screenshot and demo video.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Code written by Brad Dalton specialist for Genesis & WooCommerce.

Advertise · WPEngine · Genesis · Log in

  • Code Snippets
  • Tutorials
  • Videos
  • Tags
  • Account
  • Checkout
  • Cart
  • Hire Me
  • Log in
 

Loading Comments...