WP SITES

3082 Coded Tutorials & 284 Plugins

Coupon Order Quantity Matching for WooCommerce

(1 customer review)
$75.00

This plugin includes all the features included in this coupon generation plugin plus additional controls for :

Smart Quantity Matching

  • Automatically matches the exact quantity of items purchased
  • If a customer buys 5 items, they get a coupon for exactly 5 more items

Strict Cart Validation

  • Prevents customers from using coupons with wrong quantities
  • Shows clear error messages when quantities don’t match
  • Automatically removes invalid coupons from the cart
  • Stops checkout if the quantity doesn’t match exactly

Anti-Abuse Protection

  • Prevents customers from getting multiple coupons
  • If an order already uses a coupon, no new coupon is generated
  • Stops coupon stacking and abuse of the system

Flexible Usage Restrictions

  • Set maximum quantity limits for coupon usage
  • Force exact quantity matching for 1:1 promotions
  • Restrict coupons to different products than originally purchased
  • Combine multiple restrictions for complex promotions

Smart Coupon Generation

  • Only generates coupons for qualifying orders
  • Prevents duplicate coupons
  • Works seamlessly with WooCommerce’s existing coupon system

Coupon Matching Settings

Here are the specific settings for coupon order quantity matching you can enlarge and checkout :

Here’s some screenshots you can swipe through and enlarge to checkout the plugin settings and see whether this plugin is exactly what you are looking for :

Demo Video

Shows how the order quantity matching works with coupon usage in WooCommerce.

Usage

When testing, remember to mark order status as complete because coupons will NOT be emailed until payment is complete.

Core Functions

private function __construct()
Purpose: Initializes the plugin
Hooks:

  • admin_menu
  • admin_init
  • woocommerce_order_status_completed
  • woocommerce_after_calculate_totals
  • admin_enqueue_scripts

Cart Validation

public function validate_cart_quantity($cart)
Parameters: $cart (WC_Cart object)
Purpose: Validates cart contents against coupon restrictions
Key Methods Used:

  • WC()->cart->get_applied_coupons()
  • WC()->cart->get_cart_contents_count()
  • WC()->cart->remove_coupon()
  • wc_add_notice()

Coupon Generation

public function check_and_send_coupon($order_id)
Parameters: $order_id (int)
Purpose: Generates and sends coupons for qualifying orders
Key Methods Used:

  • wc_get_order()
  • $order->get_coupon_codes()
  • $order->get_items()
  • $order->get_total()

Coupon Creation

private function create_and_send_coupon($order)
Parameters: $order (WC_Order object)
Purpose: Creates and configures new coupons
Key Methods Used:

  • wp_insert_post()
  • update_post_meta()
  • wp_mail()

Settings Registration

public function register_settings()
Purpose: Registers plugin settings
Key Methods Used:

  • register_setting()
  • add_settings_section()
  • add_settings_field()

Admin Interface

public function render_settings_page()
Purpose: Renders the admin settings page
Key Methods Used:

  • settings_fields()
  • do_settings_sections()
  • submit_button()

Settings Callbacks

public function force_exact_quantity_callback()
public function match_quantity_callback()
public function maximum_quantity_callback()
Purpose: Handle individual settings fields
Key Methods Used:

  • get_option()
  • selected()
  • esc_html__()

Order Status Tracking

public function log_order_status_change($order_id, $old_status, $new_status)
Parameters:

  • $order_id (int)
  • $old_status (string)
  • $new_status (string)

Purpose: Logs order status changes
Key Methods Used:

  • error_log()

Admin Scripts

public function enqueue_admin_scripts($hook)
Parameters: $hook (string)
Purpose: Loads admin scripts and styles
Key Methods Used:

  • wp_enqueue_style()
  • wp_enqueue_script()
  • wp_localize_script()

Section Callback

public function section_callback()
Purpose: Renders settings section descriptions
Key Methods Used:

  • esc_html__()

WooCommerce Integration Methods

WC_Coupon methods:

  • get_limit_usage_to_x_items()
  • get_coupon_amount()
  • get_discount_type()

WC_Order methods:

  • get_billing_email()
  • get_billing_first_name()
  • get_items()
  • get_total()

WC_Cart methods:

  • get_applied_coupons()
  • get_cart_contents_count()
  • remove_coupon()
  • is_empty()

WordPress Core Functions

  • wp_insert_post()
  • update_post_meta()
  • get_option()
  • wp_mail()
  • add_action()
  • add_filter()
  • error_log()

Security Functions

  • esc_html__()
  • esc_attr()
  • esc_textarea()
  • wp_kses_post()
  • current_user_can()

Utility Functions

  • strtotime()
  • date_i18n()
  • implode()
  • array_map()
  • array_keys()
  • array_values()

1 review for Coupon Order Quantity Matching for WooCommerce

  1. Lauren (verified owner)

    Hi we had this designed for us by Brad. He did it quickly in one day. The client really likes it, and it works well for them. You can pick categories to assign a discount to. Dates. You can pick the size of discount and other properties for the discount from an easy form screen. A++. Great way to get your client to purchase more in 72 hrs!

Only logged in customers who have purchased this product may leave a review.

Contact Us If You Have Any Questions

Go back

Your message has been sent

Warning
Warning
Warning
Warning.