first commit
This commit is contained in:
23
bundles/External/PompoBundle/Ordering/Delivery/OdberNaProdejne.php
vendored
Normal file
23
bundles/External/PompoBundle/Ordering/Delivery/OdberNaProdejne.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace External\PompoBundle\Ordering\Delivery;
|
||||
|
||||
use KupShop\OrderingBundle\Entity\Purchase\PurchaseState;
|
||||
|
||||
\Delivery::includeClass('OdberNaProdejne');
|
||||
|
||||
class OdberNaProdejne extends \OdberNaProdejne
|
||||
{
|
||||
public bool $restrictionsEnabled = false;
|
||||
|
||||
public function checkRestrictions(PurchaseState $purchaseState)
|
||||
{
|
||||
if ($this->restrictionsEnabled) {
|
||||
return parent::checkRestrictions($purchaseState);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
48
bundles/External/PompoBundle/Ordering/Triggers/POSTrigger.php
vendored
Normal file
48
bundles/External/PompoBundle/Ordering/Triggers/POSTrigger.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace External\PompoBundle\Ordering\Triggers;
|
||||
|
||||
use KupShop\AdminBundle\Util\LegacyAdminCredentials;
|
||||
use KupShop\OrderDiscountBundle\Triggers\AbstractTrigger;
|
||||
use KupShop\OrderingBundle\Entity\Purchase\PurchaseState;
|
||||
|
||||
class POSTrigger extends AbstractTrigger
|
||||
{
|
||||
/** @required */
|
||||
public LegacyAdminCredentials $legacyAdminCredentials;
|
||||
|
||||
protected static $type = 'pompo_pos';
|
||||
protected $adminTemplate = 'triggers/pompo_pos.tpl';
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return '[PompoAPI] Lze uplatnit na pokladnách';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return 'Lze uplatnit na pokladně';
|
||||
}
|
||||
|
||||
public function getDiscountFilterSpec(PurchaseState $purchaseState)
|
||||
{
|
||||
// pokud je to API volani z pokladny
|
||||
if ($this->isPompoApi($purchaseState)) {
|
||||
// vyhodim vsechny slevy, ktere se nedaji uplatnit na pokladne
|
||||
return '(SELECT odt_pompo.type FROM order_discounts_triggers odt_pompo WHERE odt_pompo.type = "'.static::getType().'" AND odt_pompo.id_order_discount = odt.id_order_discount) IS NULL';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function isPompoApi(PurchaseState $purchaseState): bool
|
||||
{
|
||||
if ($purchaseState->getCustomData('isPompoApi')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
70
bundles/External/PompoBundle/Ordering/Triggers/TransportChargeTrigger.php
vendored
Normal file
70
bundles/External/PompoBundle/Ordering/Triggers/TransportChargeTrigger.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace External\PompoBundle\Ordering\Triggers;
|
||||
|
||||
use External\PompoBundle\Util\Configuration;
|
||||
use External\PompoBundle\Util\Ordering\OrderingUtil;
|
||||
use External\PompoBundle\Util\Ordering\OrderType;
|
||||
use KupShop\OrderDiscountBundle\Entity\OrderDiscount;
|
||||
use KupShop\OrderDiscountBundle\Triggers\AbstractTrigger;
|
||||
use KupShop\OrderingBundle\Cart;
|
||||
use KupShop\OrderingBundle\Entity\Purchase\PurchaseState;
|
||||
use KupShop\SellerBundle\Utils\SellerUtil;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
|
||||
class TransportChargeTrigger extends AbstractTrigger
|
||||
{
|
||||
#[Required]
|
||||
public Cart $cart;
|
||||
#[Required]
|
||||
public OrderingUtil $orderingUtil;
|
||||
#[Required]
|
||||
public Configuration $configuration;
|
||||
|
||||
public ?SellerUtil $sellerUtil = null;
|
||||
|
||||
protected static $type = 'pompo_transport_charge';
|
||||
protected $adminTemplate = 'triggers/pompo_transport_charge.tpl';
|
||||
|
||||
#[Required]
|
||||
public function setSellerUtil(?SellerUtil $sellerUtil): void
|
||||
{
|
||||
$this->sellerUtil = $sellerUtil;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'Manipulační poplatek';
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return 'Pokud splňuje podmínky pro manipulační poplatek';
|
||||
}
|
||||
|
||||
public function isApplicable(PurchaseState $purchaseState, OrderDiscount $orderDiscount, array $data, ?array $persistentData = null): bool
|
||||
{
|
||||
if (!getVal('OrderNext') && ($this->cart->actualStep === 'cart' || !$this->cart->delivery_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// pokud je nasetovany sellerId
|
||||
if ($sellerId = ($this->cart->deliveryData['seller_id'] ?? false)) {
|
||||
$type = $this->orderingUtil->getPurchaseStateOrderType($purchaseState, (int) $sellerId);
|
||||
// pokud se jedna o rezervaci s prevozem, tak splnuju podminku pro manipulacni poplatek
|
||||
if ($type === OrderType::ORDER_TRANSPORT_RESERVATION) {
|
||||
$seller = $this->sellerUtil->getSeller((int) $sellerId);
|
||||
// pokud se jedna o prodejnu s hlavnim skladem, tak tam neni manipulacni poplatek
|
||||
if ($seller['id_store'] === $this->configuration->getMainStoreId()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user