ver. 0.292: ShopProduct + ShopPaymentMethod + ShopPromotion + ShopStatuses + ShopTransport frontend migration to Domain
Full migration of front\factory\ — entire directory removed (all 20 classes migrated). ProductRepository +20 frontend methods, PromotionRepository +5 applyType methods, TransportRepository +4 cached methods, PaymentMethodRepository +cached frontend methods. Fix: broken transports_list() in ajax.php replaced with forPaymentMethod(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -331,7 +331,7 @@ class Order implements \ArrayAccess
|
||||
if ( !(int)$this -> apilo_order_id )
|
||||
return true;
|
||||
|
||||
$payment_type = (int)\front\factory\ShopPaymentMethod::get_apilo_payment_method_id( (int)$this -> payment_method_id );
|
||||
$payment_type = (int)( new \Domain\PaymentMethod\PaymentMethodRepository( $mdb ) )->getApiloPaymentTypeId( (int)$this -> payment_method_id );
|
||||
if ( $payment_type <= 0 )
|
||||
$payment_type = 1;
|
||||
|
||||
@@ -390,7 +390,7 @@ class Order implements \ArrayAccess
|
||||
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( [
|
||||
'id' => $this -> apilo_order_id,
|
||||
'status' => (int)\front\factory\ShopStatuses::get_apilo_status_id( $status )
|
||||
'status' => (int)( new \Domain\ShopStatus\ShopStatusRepository( $mdb ) )->getApiloStatusId( (int)$status )
|
||||
] ) );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, [
|
||||
"Authorization: Bearer " . $access_token,
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
namespace shop;
|
||||
|
||||
class PaymentMethod implements \ArrayAccess
|
||||
{
|
||||
private static function repo(): \Domain\PaymentMethod\PaymentMethodRepository
|
||||
{
|
||||
global $mdb;
|
||||
return new \Domain\PaymentMethod\PaymentMethodRepository( $mdb );
|
||||
}
|
||||
|
||||
// lista dostepnych form platnosci
|
||||
static public function method_list()
|
||||
{
|
||||
return self::repo()->allActive();
|
||||
}
|
||||
|
||||
// get_apilo_payment_method_id
|
||||
static public function get_apilo_payment_method_id( $payment_method_id )
|
||||
{
|
||||
return self::repo()->getApiloPaymentTypeId( (int)$payment_method_id );
|
||||
}
|
||||
|
||||
public function offsetExists( $offset )
|
||||
{
|
||||
return isset( $this -> $offset );
|
||||
}
|
||||
|
||||
public function offsetGet( $offset )
|
||||
{
|
||||
return $this -> $offset;
|
||||
}
|
||||
|
||||
public function offsetSet( $offset, $value )
|
||||
{
|
||||
$this -> $offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset( $offset )
|
||||
{
|
||||
unset( $this -> $offset );
|
||||
}
|
||||
}
|
||||
@@ -344,7 +344,7 @@ class Product implements \ArrayAccess
|
||||
|
||||
foreach ( $products as $product_id )
|
||||
{
|
||||
if ( !\front\factory\ShopProduct::is_product_active( $product_id ) )
|
||||
if ( !( new \Domain\Product\ProductRepository( $mdb ) )->isProductActiveCached( (int)$product_id ) )
|
||||
$products = array_diff( $products, [ $product_id ] );
|
||||
}
|
||||
|
||||
@@ -739,14 +739,14 @@ class Product implements \ArrayAccess
|
||||
|
||||
if ( $quantity )
|
||||
{
|
||||
if ( $msg = \front\factory\ShopProduct::warehouse_message_nonzero( $id_product, $lang_id ) )
|
||||
if ( $msg = ( new \Domain\Product\ProductRepository( $mdb ) )->getWarehouseMessageNonzero( (int)$id_product, $lang_id ) )
|
||||
$result = [ 'msg' => $msg, 'quantity' => $quantity ];
|
||||
else if ( $settings[ 'warehouse_message_nonzero_' . $lang_id ] )
|
||||
$result = [ 'msg' => $settings[ 'warehouse_message_nonzero_' . $lang_id ], 'quantity' => $quantity ];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $msg = \front\factory\ShopProduct::warehouse_message_zero( $id_product, $lang_id ) )
|
||||
if ( $msg = ( new \Domain\Product\ProductRepository( $mdb ) )->getWarehouseMessageZero( (int)$id_product, $lang_id ) )
|
||||
$result = [ 'msg' => $msg, 'quantity' => $quantity ];
|
||||
else if ( $settings[ 'warehouse_message_zero_' . $lang_id ] )
|
||||
$result = [ 'msg' => $settings[ 'warehouse_message_zero_' . $lang_id ], 'quantity' => $quantity ];
|
||||
|
||||
@@ -74,29 +74,31 @@ class Promotion
|
||||
$results = self::get_active_promotions();
|
||||
if ( is_array( $results ) and count( $results ) )
|
||||
{
|
||||
$promoRepo = new \Domain\Promotion\PromotionRepository( $mdb );
|
||||
|
||||
foreach ( $results as $row )
|
||||
{
|
||||
$promotion = new \shop\Promotion( $row );
|
||||
|
||||
// Promocja na cały koszyk
|
||||
if ( $promotion -> condition_type == 4 )
|
||||
return \front\factory\ShopPromotion::promotion_type_05( $basket_tmp, $promotion );
|
||||
return $promoRepo->applyTypeWholeBasket( $basket_tmp, $promotion );
|
||||
|
||||
// Najtańszy produkt w koszyku (z wybranych kategorii) za X zł
|
||||
if ( $promotion -> condition_type == 3 )
|
||||
return \front\factory\ShopPromotion::promotion_type_04( $basket_tmp, $promotion );
|
||||
return $promoRepo->applyTypeCheapestProduct( $basket_tmp, $promotion );
|
||||
|
||||
// Rabat procentowy na produkty z kategorii 1 lub kategorii 2
|
||||
if ( $promotion -> condition_type == 5 )
|
||||
return \front\factory\ShopPromotion::promotion_type_03( $basket_tmp, $promotion );
|
||||
return $promoRepo->applyTypeCategoriesOr( $basket_tmp, $promotion );
|
||||
|
||||
// Rabat procentowy na produkty z kategorii I i kategorii II
|
||||
if ( $promotion -> condition_type == 2 )
|
||||
return \front\factory\ShopPromotion::promotion_type_02( $basket_tmp, $promotion );
|
||||
return $promoRepo->applyTypeCategoriesAnd( $basket_tmp, $promotion );
|
||||
|
||||
// Rabat procentowy na produkty z kategorii I jeżeli w koszyku jest produkt z kategorii II
|
||||
if ( $promotion -> condition_type == 1 )
|
||||
return \front\factory\ShopPromotion::promotion_type_01( $basket_tmp, $promotion );
|
||||
return $promoRepo->applyTypeCategoryCondition( $basket_tmp, $promotion );
|
||||
}
|
||||
}
|
||||
return $basket;
|
||||
|
||||
Reference in New Issue
Block a user