Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/classes/shopShipping.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,12 @@ public static function extendItems(&$items, $units = array())

if ($dimensions = self::getShopSettings('shipping_dimensions')) {
$dimensions = preg_split('@\D+@', $dimensions);
$features = $feature_model->getByField((count($dimensions) == 1) ? 'parent_id' : 'id', $dimensions, true);
$features = $feature_model->getByField((count($dimensions) == 1) ? 'parent_id' : 'id', $dimensions, 'id');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно сохранить в ключах массива id характеристики, чтобы в цикле ниже найти информацию о характеристике по ее id.


if (count($features) == 3) {
$map += array_combine($dimension_fields, array_values($features));
foreach($dimension_fields as $dimension_field_key => $dimension_field) {
$map[$dimension_field] = $features[$dimensions[$dimension_field_key]];
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для понимания что было раньше и как сейчас будет работать.

$dimensions = [ 94, 92, 93 ]
$dimension_fields = [ 'height', 'width', 'length' ]

До исправления:

$map = [ 'height' => [ 'id' => 92, ... ], 'width' => [ 'id' => 93, ... ], 'length' => [ 'id' => 94, ... ] ]

После:

$map = [ 'height' => [ 'id' => 94, ... ], 'width' => [ 'id' => 92, ... ], 'length' => [ 'id' => 93, ... ] ]

if (isset($units['dimensions'])) {
foreach ($dimension_fields as $field) {
$units[$field] = $units['dimensions'];
Expand Down