-2

The Wooccommerce Composite Product extension allows you to create one product which is the combination of a base product and one or more component products. It's like having one or more small boxes inside one big box and the one big box inside an even bigger box. The quantities of the small boxes inside the one big box can be increased, and the quantity of the one big box can also be increased, but the even bigger box is the resulting product.

I have a base product (skateboard), and I have component products (trucks, wheels, etc.) that can be optionally added to the overall order. The quantities of the component products can be increased, same as the quantity of the base product.

The problem is when the quantity of the base product is increased, the quantity of the component product is multiplied by the the amount of the base product quantity, resulting in a larger quantity of component product being added to the cart.

Example: I want to order two skateboards and TWO trucks for the board. When I click the 'Add To Cart' button, the plugin calculates the price of two boards and FOUR trucks.

Here is a link to the Composite Product

Here is a link to the order results in the cart page

The resulting total should be $60 = (2x$10)+(2x$20), NOT $100 = 2[(2x$20)+$10]

Balwinder Singh
  • 2,272
  • 5
  • 23
  • 34
  • I found the solution to this problem. To do so, I had to modify the code in the class-wc-cp-cart.php file located in the includes folder. Had to divide the composite component quantity by the base product quantity in two places. Line 432: $quantity = $item_quantity * $composite_quantity/$item_quantity; Line 1184: $quantity = $composited_product->is_sold_individually() ? 1 : $item_quantity * $composite_quantity/$item_quantity; – user3419108 May 28 '18 at 18:13

1 Answers1

0

I found the solution to this problem. To do so, I had to modify the code in the class-wc-cp-cart.php file located in the includes folder. Had to divide the composite component quantity by the base product quantity in two places.

Line 432: $quantity = $item_quantity * $composite_quantity/$item_quantity;

Line 1184: $quantity = $composited_product->is_sold_individually() ? 1 : $item_quantity * $composite_quantity/$item_quantity;