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:
2026-02-17 21:55:16 +01:00
parent 827b903e1e
commit 89d9e61bec
48 changed files with 1780 additions and 975 deletions

View File

@@ -287,6 +287,135 @@ class TransportRepository
return $transports;
}
// =========================================================================
// Frontend methods (migrated from front\factory\ShopTransport)
// =========================================================================
/**
* Lista metod transportu dla koszyka (z filtrowaniem wagi + darmowa dostawa)
*/
public function transportMethodsFront( $basket, $coupon ): array
{
global $settings;
$cacheHandler = new \Shared\Cache\CacheHandler();
$cacheKey = 'transport_methods_front';
$cached = $cacheHandler->get( $cacheKey );
if ( $cached )
{
$transports_tmp = unserialize( $cached );
}
else
{
$transports_tmp = $this->allActive();
$cacheHandler->set( $cacheKey, $transports_tmp );
}
$wp_summary = \Domain\Basket\BasketCalculator::summaryWp( $basket );
$transports = [];
foreach ( $transports_tmp as $tr )
{
if ( $tr['max_wp'] == null )
$transports[] = $tr;
elseif ( $tr['max_wp'] != null and $wp_summary <= $tr['max_wp'] )
$transports[] = $tr;
}
if ( \Shared\Helpers\Helpers::normalize_decimal( \Domain\Basket\BasketCalculator::summaryPrice( $basket, $coupon ) ) >= \Shared\Helpers\Helpers::normalize_decimal( $settings['free_delivery'] ) )
{
for ( $i = 0; $i < count( $transports ); $i++ ) {
if ( $transports[$i]['delivery_free'] == 1 ) {
$transports[$i]['cost'] = 0.00;
}
}
}
return $transports;
}
/**
* Koszt transportu z cache
*/
public function transportCostCached( $transportId )
{
$cacheHandler = new \Shared\Cache\CacheHandler();
$cacheKey = 'transport_cost_' . $transportId;
$cached = $cacheHandler->get( $cacheKey );
if ( $cached )
{
return unserialize( $cached );
}
$cost = $this->getTransportCost( (int)$transportId );
$cacheHandler->set( $cacheKey, $cost );
return $cost;
}
/**
* Aktywny transport z cache
*/
public function findActiveByIdCached( $transportId )
{
$cacheHandler = new \Shared\Cache\CacheHandler();
$cacheKey = 'transport' . $transportId;
$cached = $cacheHandler->get( $cacheKey );
if ( $cached )
{
return unserialize( $cached );
}
$transport = $this->findActiveById( (int)$transportId );
$cacheHandler->set( $cacheKey, $transport );
return $transport;
}
/**
* Transporty powiązane z metodą płatności
*/
public function forPaymentMethod( int $paymentMethodId ): array
{
if ( $paymentMethodId <= 0 )
{
return [];
}
$transportIds = $this->db->select(
'pp_shop_transport_payment_methods',
'id_transport',
['id_payment_method' => $paymentMethodId]
);
if ( !is_array( $transportIds ) || empty( $transportIds ) )
{
return [];
}
$transports = $this->db->select(
'pp_shop_transports',
'*',
['AND' => ['id' => $transportIds, 'status' => 1], 'ORDER' => ['o' => 'ASC']]
);
if ( !is_array( $transports ) )
{
return [];
}
foreach ( $transports as &$transport )
{
$transport = $this->normalizeTransport( $transport );
}
unset( $transport );
return $transports;
}
private function savePaymentMethodLinks(int $transportId, $paymentMethods): void
{
if (is_array($paymentMethods)) {