Files
shopPRO/autoload/front/factory/class.ShopTransport.php
Jacek Pyziak d824ba3909 Integrations DI refactor, remove Sellasist/Baselinker, fix product-edit encoding (0.263)
- New: Domain\Integrations\IntegrationsRepository + admin\Controllers\IntegrationsController (DI)
- Cleanup: removed all Sellasist and Baselinker integrations from entire project
- Fix: product-edit.php Polish characters (UTF-8/CP1250 double-encoding)
- Update: factory\Integrations as facade (Apilo + ShopPRO only)
- Tests: 212 tests, 577 assertions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 21:59:26 +01:00

96 lines
2.8 KiB
PHP

<?php
namespace front\factory;
class ShopTransport
{
// get_apilo_carrier_account_id
static public function get_apilo_carrier_account_id( $transport_method_id )
{
global $mdb;
return $mdb -> get( 'pp_shop_transports', 'apilo_carrier_account_id', [ 'id' => $transport_method_id ] );
}
public static function transport_methods( $basket, $coupon )
{
global $mdb, $settings;
$cacheHandler = new \CacheHandler();
$cacheKey = "\front\factory\ShopTransport::transport_methods";
$objectData = $cacheHandler -> get( $cacheKey );
if ( !$objectData )
{
$results = $mdb -> query( 'SELECT '
. 'pst.id, name, name_visible, description, cost, max_wp, pst.default, delivery_free '
. 'FROM '
. 'pp_shop_transports AS pst '
. 'WHERE '
. 'status = 1 ORDER BY o ASC' ) -> fetchAll( \PDO::FETCH_ASSOC );
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
$transports_tmp[] = $row;
$cacheHandler -> set( $cacheKey, $transports_tmp );
}
else
{
$transports_tmp = unserialize( $objectData );
}
$wp_summary = \front\factory\ShopBasket::summary_wp( $basket );
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 ( \S::normalize_decimal( \front\factory\ShopBasket::summary_price( $basket, $coupon ) ) >= \S::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;
}
public static function transport_cost( $transport_id )
{
global $mdb;
if ( !$cost = \Cache::fetch( 'transport_cost_' . $transport_id ) )
{
$cost = $mdb -> get( 'pp_shop_transports', 'cost', [
'AND' => [
'id' => $transport_id,
'status' => 1
] ] );
\Cache::store( 'transport_cost_' . $transport_id, $cost );
}
return $cost;
}
public static function transport( $transport_id )
{
global $mdb;
if ( !$transport = \Cache::fetch( 'transport' . $transport_id ) )
{
$transport = $mdb -> get( 'pp_shop_transports', '*', [
'AND' => [
'id' => $transport_id,
'status' => 1
] ] );
\Cache::store( 'transport' . $transport_id, $transport );
}
return $transport;
}
}