Viewing 15 replies - 1 through 15 (of 17 total)
  • Hello,

    I would like to know if you are still experiencing issues with the plugin. If so, please contact us through our live chat here, as we have an update that addresses this problem.

    Thank you.

    Hello,

    I followed the configuration suggested by the screenshots and I was able to apply the discounts on the cart and the checkout.

    In order to solve the problem as soon as possible, can you please tell us the version of the plugin you are experiencing the problem with?

    And can you share your WooCommerce status page ( You can find it in the WooCommerce menu WooCommerce>Status>System status ) .

    Thank you.

    Thread Starter winzyatan

    (@winzyatan)

    My current plugin version is 2.31.3.

    WooCommerce status: YFwNBQm95W (inote.net)

    Thread Starter winzyatan

    (@winzyatan)

    Example:

    My product ID is 2919 and its price is 450000 (image). It is a footwear product and has many variations (many sizes).

    I added it to a list named ‘10%’ (image).

    I created a 10% discount based on that list (image).

    Then I added a variation of the product to the cart (example: size 39). But when I go to the checkout page, its price is still not reduced (image).

    I have been able to locate the issue and have a solution for the issue you encountered with the variations. You can implement the following code into the file wp-content/plugins/woo-advanced-discounts/includes/class-wad-products-list.php at line 752:

    if ( ! empty( $parents_ids_str ) ) {
    $results = $wpdb->get_col(
    $wpdb->prepare( "SELECT DISTINCT id FROM $wpdb->posts WHERE post_parent IN ($parents_ids_str) AND post_type = %s",
    'product_variation'
    )
    );
    }

    Let me know, if it resolves the issue you’re encountering.

    Thread Starter winzyatan

    (@winzyatan)

    OK, thank you. Its price has been reduced at the checkout page.

    But I have another list including all products that exclude it (image).

    I created a 10% off discount based on that list (image).

    And when I go to the checkout page, its price is still 10% off twice (i.e. it is not excluded from the “All products” list) (image).

    As you know, its original price is 450000.

    Regarding the issue where the discount is applied twice on the checkout page, you need to modify the following file: wp-content/plugins/woo-advanced-discounts/includes/class-wad-products-list.php.

    Go to line 682 and replace the existing if condition with this code:

    if (isset($args['post__not_in']) && !empty($args['post__not_in'])) {
    $wad_last_products_fetch = array_diff($wad_last_products_fetch, array_map('intval', $args['post__not_in']));
    }

    This modification should resolve the issue with the double discount on the checkout page.

    Thread Starter winzyatan

    (@winzyatan)

    I’ve modified that file as you said (image).

    But the price in the cart and the checkout page is still reduced twice (even though the price on the product page is correct) (image).

    And the double discount shows that this product is not excluded from the “All products” list even though I added its ID (2919) to the “Exclude” box.

    As I said yesterday, I have another list named “All products” which includes all products except it (image), and have a 10% off discount based on that list (image).

    The code provided earlier is working.

    After editing the code, could you please go to the product list screen, evaluate, and let me know if the excluded product is still displayed there?

    If not, the price will not be discounted twice.

    Thread Starter winzyatan

    (@winzyatan)

    After excluding ID 2919 and pressing ‘Evaluate’, its subvariants are still displayed. Only the parent product (ID 2919) is not. (image)

    I observed the same issue, and I have a solution for you. You’ll need to modify the code in the file class-wad-products-list.php at line 629. Replace the existing if ('post__not_in') condition with the following code:

    if ('post__not_in' == $parameter) {
        $args[$parameter] = array_map('intval', explode(',', $raw_args[$parameter]));
    
        $products = wc_get_products(array('type' => 'variable', 'include' => $args[$parameter]));
    
        if (!empty($products)) {
            $variations = array_reduce(
                array_map(
                    function ($e) {
                        return $e->get_children();
                    },
                    $products
                ),
                function ($carry, $item) {
                    return array_merge($carry, $item);
                },
                []
            );
    
            $args[$parameter] = array_merge($args[$parameter], $variations);
        }
    }
    
    Thread Starter winzyatan

    (@winzyatan)

    OK, now its price on the Checkout page has been properly reduced.
    Only the price on the Product page has not been updated yet (image)

    Thread Starter winzyatan

    (@winzyatan)

    Hi,

    Will you keep updating?

    Plugin Author Donald FALY

    (@donaldlaly)

    Hello @winzyatan an update has been sent. let me know if it fixes your problem.

    Thread Starter winzyatan

    (@winzyatan)

    Hello. Now the price is reduced by 10% twice again on the checkout page and cart. Only the price on the product page is correct. (image)

    Even though I excluded its ID from the ‘All products’ list (image).

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Cannot discount by product ID if the product has multiple variations’ is closed to new replies.