Sometimes you need 2 or 3 times more mandatory accessories for a main product. For example your main product smartphone requires 2 chargers instead of just one.

In this case you can use the following filter. Place that in your child theme functions.php. Then adjust the quantity and the accessory ID.

// Adjust mandatory quantity for accessory with ID 378
add_filter('woocommerce_product_accessories_mandatory_quantity', function($quantity, $accessory_id) {


	if($accessory_id == 378) {
		$quantity = $quantity * 2;
	}

	return $quantity;

}, 20, 2);

Leave a Reply

Your email address will not be published. Required fields are marked *