Use cart item key instead of index in shipping items (https://github.com/woocommerce/woocommerce-blocks/pull/8199)

* use cart item key instead of index

* Update src/StoreApi/Schemas/V1/CartShippingRateSchema.php

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
This commit is contained in:
Seghir Nadir 2023-01-23 15:45:10 +01:00 committed by GitHub
parent 018af7c3af
commit 637c1a735f
1 changed files with 2 additions and 2 deletions

View File

@ -260,9 +260,9 @@ class CartShippingRateSchema extends AbstractSchema {
*/ */
protected function prepare_package_items_response( $package ) { protected function prepare_package_items_response( $package ) {
$items = array(); $items = array();
foreach ( $package['contents'] as $item_id => $values ) { foreach ( $package['contents'] as $values ) {
$items[] = [ $items[] = [
'key' => $item_id, 'key' => $values['key'],
'name' => $values['data']->get_name(), 'name' => $values['data']->get_name(),
'quantity' => $values['quantity'], 'quantity' => $values['quantity'],
]; ];