Zaktualizuj wersję na 0.222, dodaj integrację z Orlen Paczka oraz wprowadź zmiany w obsłudze punktów Orlen w formularzach zamówień i koszyka
This commit is contained in:
80
cron.php
80
cron.php
@@ -52,7 +52,8 @@ $apilo_settings = \admin\factory\Integrations::apilo_settings();
|
||||
$baselinker_settings = \admin\factory\Integrations::baselinker_settings();
|
||||
$sellasist_settings = \admin\factory\Integrations::sellasist_settings();
|
||||
|
||||
function parsePaczkomatAddress($input) {
|
||||
function parsePaczkomatAddress($input)
|
||||
{
|
||||
$pattern = '/^(\w+)\s+\|\s+([^,]+),\s+(\d{2}-\d{3})\s+(.+)$/';
|
||||
|
||||
if (preg_match($pattern, $input, $matches)) {
|
||||
@@ -67,6 +68,21 @@ function parsePaczkomatAddress($input) {
|
||||
}
|
||||
}
|
||||
|
||||
function parseOrlenAddress( $input )
|
||||
{
|
||||
$pattern = '/^([^\|]+)\s*\|\s*([^,]+),\s*(.+?)\s+(\d{2}-\d{3})$/';
|
||||
if (preg_match($pattern, $input, $matches)) {
|
||||
return [
|
||||
'code' => trim($matches[1]),
|
||||
'address' => trim($matches[2]),
|
||||
'city' => trim($matches[3]),
|
||||
'postalCode' => trim($matches[4]),
|
||||
];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getImageUrlById($id) {
|
||||
$apiUrl = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['SERVER_NAME'] . '/api/v1/product.php';
|
||||
|
||||
@@ -118,7 +134,7 @@ if ( $sellasist_settings['enabled'] and $sellasist_settings['sync_products'] and
|
||||
|
||||
$mdb -> update( 'pp_shop_products', [ 'price_netto' => \S::normalize_decimal( $price_netto, 2 ), 'price_brutto' => \S::normalize_decimal( $price_brutto, 2 ) ], [ 'sellasist_product_id' => $result['sellasist_product_id'] ] );
|
||||
|
||||
\admin\factory\ShopProduct::update_product_combinations_prices( $result['id'], $price_brutto, $vat, null );
|
||||
\admin\factory\ShopProduct::update_product_combinations_prices( (int)$result['id'], $price_brutto, $vat, null );
|
||||
}
|
||||
|
||||
// aktualizowanie stanu magazynowego
|
||||
@@ -190,7 +206,7 @@ if ( $apilo_settings['enabled'] and $apilo_settings['access-token'] and ( !$apil
|
||||
$mdb -> update( 'pp_shop_products', [ 'price_netto' => \S::normalize_decimal( $price_netto, 2 ), 'price_brutto' => \S::normalize_decimal( $price_brutto, 2 ) ], [ 'apilo_product_id' => $product_price['product'] ] );
|
||||
$product_id = $mdb -> get( 'pp_shop_products', 'id', [ 'apilo_product_id' => $product_price['product'] ] );
|
||||
|
||||
\admin\factory\ShopProduct::update_product_combinations_prices( $product_id, $price_brutto, $vat, null );
|
||||
\admin\factory\ShopProduct::update_product_combinations_prices( (int)$product_id, $price_brutto, $vat, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,7 +263,7 @@ if ( $baselinker_settings['enabled'] and $baselinker_settings['sync_products'] a
|
||||
$product_id = $mdb -> get( 'pp_shop_products', 'id', [ 'baselinker_product_id' => $baselinker_product_id ] );
|
||||
$vat = $mdb -> get( 'pp_shop_products', 'vat', [ 'baselinker_product_id' => $baselinker_product_id ] );
|
||||
|
||||
\admin\factory\ShopProduct::update_product_combinations_prices( $product_id, $price_brutto, $vat, $price_brutto_promo );
|
||||
\admin\factory\ShopProduct::update_product_combinations_prices( (int)$product_id, $price_brutto, $vat, $price_brutto_promo );
|
||||
}
|
||||
|
||||
// aktualizowanie wagi
|
||||
@@ -489,6 +505,29 @@ if ( $apilo_settings['enabled'] and $apilo_settings['sync_orders'] and $apilo_se
|
||||
$order_date = new DateTime( $order['date_order'] );
|
||||
|
||||
$paczkomatData = parsePaczkomatAddress( $order['inpost_paczkomat'] );
|
||||
$orlenPointData = parseOrlenAddress( $order['orlen_point'] );
|
||||
|
||||
$street = '';
|
||||
$city = '';
|
||||
$postal_code = '';
|
||||
if ( $order['client_street'] )
|
||||
{
|
||||
$street = $order['client_street'];
|
||||
$city = $order['client_city'];
|
||||
$postal_code = $order['client_postal_code'];
|
||||
}
|
||||
else if ( $paczkomatData )
|
||||
{
|
||||
$street = $paczkomatData['address'];
|
||||
$city = $paczkomatData['city'];
|
||||
$postal_code = $paczkomatData['postalCode'];
|
||||
}
|
||||
else if ( $orlenPointData )
|
||||
{
|
||||
$street = $orlenPointData['address'];
|
||||
$city = $orlenPointData['city'];
|
||||
$postal_code = $orlenPointData['postalCode'];
|
||||
}
|
||||
|
||||
$postData = [
|
||||
'idExternal' => $order['id'],
|
||||
@@ -503,17 +542,17 @@ if ( $apilo_settings['enabled'] and $apilo_settings['sync_orders'] and $apilo_se
|
||||
'name' => $order['client_name'] . ' ' . $order['client_surname'],
|
||||
'phone' => $order['client_phone'],
|
||||
'email' => $order['client_email'],
|
||||
'streetName' => $order['client_street'] ? $order['client_street'] : $paczkomatData['address'],
|
||||
'city' => $order['client_city'] ? $order['client_city'] : $paczkomatData['city'],
|
||||
'zipCode' => $order['client_postal_code'] ? $order['client_postal_code'] : $paczkomatData['postalCode']
|
||||
'streetName' => $street,
|
||||
'city' => $city,
|
||||
'zipCode' => $postal_code
|
||||
],
|
||||
'addressDelivery' => [
|
||||
'name' => $order['client_name'] . ' ' . $order['client_surname'],
|
||||
'phone' => $order['client_phone'],
|
||||
'email' => $order['client_email'],
|
||||
'streetName' => $order['client_street'] ? $order['client_street'] : $paczkomatData['address'],
|
||||
'city' => $order['client_city'] ? $order['client_city'] : $paczkomatData['city'],
|
||||
'zipCode' => $order['client_postal_code'] ? $order['client_postal_code'] : $paczkomatData['postalCode']
|
||||
'streetName' => $street,
|
||||
'city' => $city,
|
||||
'zipCode' => $postal_code
|
||||
],
|
||||
'carrierAccount' => (int)\front\factory\ShopTransport::get_apilo_carrier_account_id( $order['transport_id'] ),
|
||||
'orderNotes' => [ [
|
||||
@@ -544,6 +583,27 @@ if ( $apilo_settings['enabled'] and $apilo_settings['sync_orders'] and $apilo_se
|
||||
}
|
||||
}
|
||||
|
||||
// jeżeli orlen paczka
|
||||
if ( $order['orlen_point'] )
|
||||
{
|
||||
$postData['addressDelivery']['parcelName'] = $order['orlen_point'] ? 'Automat ORLEN ' . $order['orlen_point'] : null;
|
||||
$postData['addressDelivery']['parcelIdExternal'] = $order['orlen_point'] ? ( $parcelId = trim( explode( '-', $order['orlen_point'] )[1] ) ) : null;
|
||||
|
||||
if ( !$postData['addressDelivery']['zipCode'] or !$postData['addressDelivery']['city'] )
|
||||
{
|
||||
preg_match("/\b\d{2}-\d{3}\b/", $order['orlen_point'], $postalCodeMatches);
|
||||
$postalCode = $postalCodeMatches[0] ?? '';
|
||||
|
||||
$cityPattern = "/\d{2}-\d{3}\s+(.+)/";
|
||||
preg_match($cityPattern, $order['orlen_point'], $cityMatches);
|
||||
$city = $cityMatches[1] ?? '';
|
||||
|
||||
$postData['addressDelivery']['zipCode'] = $postalCode;
|
||||
$postData['addressDelivery']['city'] = $city;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $order['paid'] )
|
||||
{
|
||||
$payment_date = new DateTime( $order['date_order'] );
|
||||
|
||||
Reference in New Issue
Block a user