Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #3654786
Plugin settings help
Open

Comments

  • Marko started the conversation

    Hello,

    For the same variable product, I need the plugin to consider all its variations as the same product when calculating tiered pricing. Right now, each variation calculates discounts for itself based on how many variation quantity is selected (and not on the product level).

    For instance: if I set discount for the whole product to be applied once 3 items are selected, and then choose one of each variation, plugin doesn't apply discount, only if the same variation gets added in quantity of 3.

  •  1,226
    Dustin replied

    Hi Marko,

    I'm so sorry for the late reply!

    Please update our plugin to the latest version, 5.1.2, and then add the custom code below. (How to add custom code? ↗):

    add_filter( 'wpcpq_cart_item_quantity', function ( $quantity, $cart_item, $cart_item_key ) {
        if ( $cart_item['data']->is_type( 'variation' ) ) {
            $parent_id = $cart_item['data']->get_parent_id();
            $quantity  = 0;
            foreach ( WC()->cart->get_cart() as $c_item ) {
                if ( $c_item['data']->get_parent_id() == $parent_id ) {
                    $quantity += $c_item['quantity'];
                }
            }
        }
        return $quantity;
    }, 99, 3 );

    Best regards,
    Dustin