ver. 0.305: Fix permutation attribute sorting + free delivery progress bar
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -80,16 +80,17 @@ class ShopProductController
|
||||
{
|
||||
global $lang_id;
|
||||
|
||||
$combination = '';
|
||||
$selected_values = \Shared\Helpers\Helpers::get( 'selected_values' );
|
||||
|
||||
foreach ( $selected_values as $value )
|
||||
{
|
||||
$combination .= $value;
|
||||
if ( $value != end( $selected_values ) )
|
||||
$combination .= '|';
|
||||
// Sort by attribute ID to match permutation_hash order (generated with ksort)
|
||||
if ( is_array( $selected_values ) ) {
|
||||
usort( $selected_values, function ( $a, $b ) {
|
||||
return (int) explode( '-', $a )[0] - (int) explode( '-', $b )[0];
|
||||
} );
|
||||
}
|
||||
|
||||
$combination = is_array( $selected_values ) ? implode( '|', $selected_values ) : '';
|
||||
|
||||
$product_id = \Shared\Helpers\Helpers::get( 'product_id' );
|
||||
$productRepo = new \Domain\Product\ProductRepository( $GLOBALS['mdb'] );
|
||||
$product = $productRepo->findCached( $product_id, $lang_id );
|
||||
@@ -102,6 +103,10 @@ class ShopProductController
|
||||
private static function getPermutation( $attributes )
|
||||
{
|
||||
if ( !is_array( $attributes ) || !count( $attributes ) ) return null;
|
||||
// Sort by attribute ID to match permutation_hash order (generated with ksort)
|
||||
usort( $attributes, function ( $a, $b ) {
|
||||
return (int) explode( '-', $a )[0] - (int) explode( '-', $b )[0];
|
||||
} );
|
||||
return implode( '|', $attributes );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user