• Resolved gekomees

    (@gekomees)


    The coupon applying function doesn’t account for variations when checking for validity.

    The fix:
    Change the $product_id = line in it’s entirety to these two lines

    $parent_id = is_callable( array( $product, 'get_parent_id' ) ) ? $product->get_parent_id() : false;
    $product_id = is_numeric($parent_id) ? $parent_id : (is_callable( array( $product, 'get_id' ) ) ?  $product->get_id() : $product->id);

    in is_valid_for_product_brand function inside /classes/admin/class-pwb-coupon.php

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor titodevera

    (@titodevera)

    Hi gekomees.

    Thank you so much for report the issue. I′m working in a new PWB release, i will fix this issue for the new version.

    ??

    Hello,

    @gekomees thank you for the helping hand and @titodevera can’t wait for the update!

    The coupon works now for variable products but doesn’t apply anymore for simple products.

    I changed this line:

    $product_id = is_callable( array( $product, ‘get_id’ ) ) ? $product->get_id() : $product->id;

    with the 2 lines mentioned above. Did I do something wrong? Could you help me with a fix?

    Thank you in advance! ??

    Thread Starter gekomees

    (@gekomees)

    Ah, yes. Since the shop I used the plugin on only has variable products this slipped under my radar. Simple products have a parent of 0, so the in_numerical check thinks it’s a variation.

    To fix:
    replace is_numeric($parent_id)
    with !empty($parent_id)

    @gekomees you are a life saver!

    Thank you very much it worked!

    Hope you have a wonderful weekend!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Coupon doesn’t work for product variations’ is closed to new replies.