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:
2026-02-22 16:33:30 +01:00
parent 5e0bf13960
commit fdb1423285
17 changed files with 2094 additions and 53 deletions

View File

@@ -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 );
}