Refactor class.Product.php and class.S.php for improved code readability and maintainability
This commit is contained in:
@@ -248,11 +248,6 @@ class ShopProduct
|
||||
if ( is_array( $results ) )
|
||||
foreach ( $results as $row )
|
||||
{
|
||||
$row[ 'require' ] = $mdb -> get( 'pp_shop_attributes',
|
||||
'required',
|
||||
[ 'id' => $row[ 'attribute_id' ] ]
|
||||
);
|
||||
|
||||
$row[ 'type' ] = $mdb -> get( 'pp_shop_attributes',
|
||||
'type',
|
||||
[ 'id' => $row[ 'attribute_id' ] ]
|
||||
@@ -301,9 +296,9 @@ class ShopProduct
|
||||
|
||||
$product[ 'products_related' ] = $mdb -> select( 'pp_shop_products_related', 'product_related_id', [ 'product_id' => (int)$product_id ] );
|
||||
|
||||
$products_sets_1 = $mdb -> select( 'pp_shop_products_sets', 'product_sets_id', [ 'product_id' => (int)$product_id ] );
|
||||
$products_sets_2 = $mdb -> select( 'pp_shop_products_sets', 'product_id', [ 'product_sets_id' => (int)$product_id ] );
|
||||
$products_sets = array_unique( array_merge( $products_sets_1, $products_sets_2 ) );
|
||||
$set_id = $mdb -> select( 'pp_shop_product_sets_products', 'set_id', [ 'product_id' => (int)$product_id ] );
|
||||
$products_sets = $mdb -> select( 'pp_shop_product_sets_products', 'product_id', [ 'set_id' => (int)$set_id ] );
|
||||
$products_sets = array_unique( $products_sets );
|
||||
|
||||
$product[ 'products_sets' ] = $products_sets;
|
||||
|
||||
@@ -338,28 +333,6 @@ class ShopProduct
|
||||
return $mdb -> get( 'pp_shop_products_langs', 'warehouse_message_nonzero', [ 'AND' => [ 'product_id' => $id_product, 'lang_id' => $lang_id ] ] );
|
||||
}
|
||||
|
||||
public static function permutation_quantity( $id_product, $permutation, bool $is_multichoice )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$is_multichoice )
|
||||
return $mdb -> get( 'pp_shop_products_stock', 'quantity', [ 'AND' => [ 'id_product' => $id_product, 'permutation' => 0 ] ] );
|
||||
|
||||
if ( is_array( $permutation ) )
|
||||
{
|
||||
foreach ( $permutation as $key => $val )
|
||||
{
|
||||
$permutation_id .= $val;
|
||||
if ( $val != end( $permutation ) )
|
||||
$permutation_id .= '_';
|
||||
}
|
||||
}
|
||||
else
|
||||
$permutation_id = $permutation;
|
||||
|
||||
return $mdb -> get( 'pp_shop_products_stock', 'quantity', [ 'AND' => [ 'id_product' => $id_product, 'permutation' => $permutation_id ] ] );
|
||||
}
|
||||
|
||||
//TO:DO do usunięcia
|
||||
public static function product_both_price( $product_id )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user