first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

View File

@@ -0,0 +1,142 @@
<?php
class Paczkomaty extends Delivery
{
public static $type = Delivery::TYPE_POINT;
public static $className = 'Paczkomaty';
protected $templateDescription = 'deliveries/delivery.Paczkomaty.description.tpl';
protected $AdminTemplateSettings = 'deliveries/block.delivery.Paczkomaty.tpl';
public static $tableName = '`kupshop_shared`.`delivery_paczkomaty`';
public static $jsonDeliveryBalikobot = 'https://test20cztest:QKCufcWs@api.balikobot.cz/pbh/branches/14';
public static $tableColumns = ['id' => 'id', 'country' => 'country', 'name' => 'name',
'zip' => 'zip', 'city' => 'city', 'address' => 'street', 'district' => 'district', 'type' => 'type', 'street' => 'street', ];
public static $excludeColumns = ['latitude', 'longitude'];
public $delivery_paczkomaty_id;
protected $track_and_trace = 'https://inpost.pl/sledzenie-przesylek?number=[PACKAGE_ID]';
public function getName()
{
$info = self::getInfo($this->delivery_paczkomaty_id);
return parent::getName().' - '.$info['name'];
}
public function storeDeliveryInfo($data)
{
$id = trim($data['paczkomaty_id'] ?? '');
$info = $this->getInfo($id);
return empty($id) ? [] : ($this->data = [
'zip' => $info['zip'],
'paczkomaty_id' => $info['id'],
]);
}
public function getInfo($id = null)
{
if (is_null($id)) {
$id = getVal('paczkomaty_id', $this->data);
}
$data = sqlFetchAssoc(sqlQueryBuilder()->select('*')
->from(self::$tableName)->where(\Query\Operator::equals(['id' => $id]))->execute());
if (!$data) {
return ['name' => translate_shop('branch_unknown', 'delivery')];
}
$data['address'] = $data['street'].', '.$data['zip'].', '.$data['city'];
return $data;
}
/**
* @param $data admin order data
* @param Order $order
*
* @return bool|string
*/
public function applyToOrder(&$data, $order)
{
parent::applyToOrder($data, $order);
$info = $this->getInfo();
if (empty($info['id'])) {
return translate_shop('branch_not_selected', 'delivery');
}
$data['delivery_zip'] = $info['zip'];
$data['delivery_street'] = $info['street'];
$data['delivery_city'] = $info['city'];
$data['delivery_country'] = $info['country'];
return true;
}
/**
* @param $cart CartBase
*/
public function applyToCart(CartBase $cart)
{
parent::applyToCart($cart);
$info = $this->getInfo();
if (empty($info['id'])) {
return;
}
if (isset($cart->invoice['name'])) {
$cart->delivery['name'] = $cart->invoice['name'];
$cart->delivery['surname'] = $cart->invoice['surname'];
}
$cart->delivery['zip'] = $info['zip'];
$cart->delivery['street'] = $info['street'];
$cart->delivery['city'] = $info['city'];
$cart->delivery['country'] = $info['country'];
}
public function printDeliveryInfo()
{
$info = $this->getInfo();
if (empty($info['id'])) {
return $info['name'];
}
return "{$info['name']}, {$info['street']}, <strong>{$info['zip']} {$info['city']}</strong>";
}
public function requiresDeliveryAddress()
{
return false;
}
public function checkSelected(Cart $cart, ?Payment $payment = null)
{
if (empty($this->data['paczkomaty_id']) && $cart->hasData('delivery')) {
throw new \KupShop\OrderingBundle\Exception\DeliveryException(translate_shop('branch_not_selected', 'delivery'));
}
return parent::checkSelected($cart, $payment);
}
public function setPointId($id): self
{
$this->data['paczkomaty_id'] = $id;
return $this;
}
public function getPointId()
{
return $this->data['paczkomaty_id'];
}
}