Plugin: Splits multiple quantities into individual cart rows
-
Good day,
Part of a plugin that I had custom written is not working after the 4.9.2 update.
The plugin, among other things, splits products in the cart that are multiple quantities into individual line items. (This is done so that additional fields can be added to those line items by the user).The code that does this is:
function split_items($merged_data, $cart_item_key) {
if ($merged_data[‘quantity’] > 1) {
while($merged_data[‘quantity’] > 1) {
$merged_data[‘uniqid’] = bin2hex(random_bytes(5));
WC()->cart->add_to_cart($merged_data[‘product_id’], 1, $merged_data[‘variation_id’], $merged_data[‘variation’], array(‘uniqid’ => bin2hex(random_bytes(5)) ) );
$merged_data[‘quantity’]–;
}
}
return $merged_data;
}Can anyone help me figure out what broke, and how to fix it?
Thanks!
The topic ‘Plugin: Splits multiple quantities into individual cart rows’ is closed to new replies.