View Categories

Wrong Product Added via Coupon URL

Table of Contents

Problem Description #

The coupon URL should add a product or variation to the cart automatically but either nothing is added, the wrong quantity is added, or the product variation is incorrect.

Symptoms

  • No product appears in cart after following URL.

  • A different product appears or a simple product added instead of the chosen variation.

  • Product added but quantity is 0 or defaults incorrectly.

Typical cause:
Incorrect product ID, using variable product without variation ID/attributes, product out of stock, or the URL format for adding products is incorrect.

Solution-step-by-step

  1. Verify product IDs and URL format

    1. Confirm you are using the correct product ID (not product SKU unless plugin supports SKU). For simple product: ?add-to-cart=123. For variation, many plugins require variation ID and attributes like ?variation_id=456&attribute_pa_color=red. Confirm plugin docs for exact format. WPFactory

  2. Confirm product status

    1. Check product is published, in stock, and purchasable (not private or restricted).

  3. Test simple product first

    1. Test the simplest case: add a simple product via URL and verify it appears in the cart. If this works, the issue is likely variation or parameter formatting.

  4. Variation handling

    1. If adding a variation, use the variation ID (not parent product ID) and ensure attributes are provided exactly as stored (attribute slugs). Example:
      https://example.com/?add-to-cart=123&variation_id=456&attribute_pa_size=large

    2. Misspelled attribute names or wrong slugs will cause fallback to parent or no addition.

  5. Check plugin-specific “empty cart” setting

    1. If the plugin empties the cart before adding products, ensure this behavior is intended; otherwise disable it to preserve cart contents. WPFactory

  6. Test for conflicts

    1. Temporarily disable plugins that manipulate cart item additions (other add-to-cart handlers, subscription plugins, or custom snippets).

Prerequisites:

  • Proper product/variation IDs.

  • Plugin version supporting auto-add products.

Additional notes:

For complex bundles or composite products, URL addition may require special handling and not be supported by a simple query parameter.

 

Coupon & Discount by User Role for WooCommerce