Subida del módulo y tema de PrestaShop

This commit is contained in:
Kaloyan
2026-04-09 18:31:51 +02:00
parent 12c253296f
commit 16b3ff9424
39262 changed files with 7418797 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
<?php
/**
* For the full copyright and license information, please view the
* docs/licenses/LICENSE.txt file that was distributed with this source code.
*/
use PrestaShop\PrestaShop\Adapter\Presenter\Object\ObjectPresenter;
use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter;
use PrestaShop\PrestaShop\Adapter\Shipment\DeliveryOptionsInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class DeliveryOptionsFinderCore implements DeliveryOptionsInterface
{
private $context;
private $objectPresenter;
private $translator;
private $priceFormatter;
public function __construct(
Context $context,
TranslatorInterface $translator,
ObjectPresenter $objectPresenter,
PriceFormatter $priceFormatter
) {
$this->context = $context;
$this->objectPresenter = $objectPresenter;
$this->translator = $translator;
$this->priceFormatter = $priceFormatter;
}
private function isFreeShipping($cart, array $carrier)
{
$free_shipping = false;
if ($carrier['is_free']) {
$free_shipping = true;
} else {
foreach ($cart->getCartRules() as $rule) {
if ($rule['free_shipping'] && !$rule['carrier_restriction']) {
$free_shipping = true;
break;
}
}
}
return $free_shipping;
}
public function getSelectedDeliveryOption()
{
return current($this->context->cart->getDeliveryOption(null, false, false));
}
public function getDeliveryOptions()
{
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
$include_taxes = !Product::getTaxCalculationMethod((int) $this->context->cart->id_customer) && (int) Configuration::get('PS_TAX');
$display_taxes_label = (Configuration::get('PS_TAX') && $this->context->country->display_tax_label);
$carriers_available = [];
if (isset($delivery_option_list[$this->context->cart->id_address_delivery])) {
foreach ($delivery_option_list[$this->context->cart->id_address_delivery] as $id_carriers_list => $carriers_list) {
foreach ($carriers_list as $carriers) {
if (is_array($carriers)) {
foreach ($carriers as $carrier) {
$carrier = array_merge($carrier, $this->objectPresenter->present($carrier['instance']));
$delay = $carrier['delay'][$this->context->language->id];
unset($carrier['instance'], $carrier['delay']);
$carrier['delay'] = $delay;
if ($this->isFreeShipping($this->context->cart, $carriers_list)) {
$carrier['price'] = $this->translator->trans(
'Free',
[],
'Shop.Theme.Checkout'
);
} else {
if ($include_taxes) {
$carrier['price'] = $this->priceFormatter->format($carriers_list['total_price_with_tax']);
if ($display_taxes_label) {
$carrier['price'] = $this->translator->trans(
'%price% tax incl.',
['%price%' => $carrier['price']],
'Shop.Theme.Checkout'
);
}
} else {
$carrier['price'] = $this->priceFormatter->format($carriers_list['total_price_without_tax']);
if ($display_taxes_label) {
$carrier['price'] = $this->translator->trans(
'%price% tax excl.',
['%price%' => $carrier['price']],
'Shop.Theme.Checkout'
);
}
}
}
if (count($carriers) > 1) {
$carrier['label'] = $carrier['price'];
} else {
$carrier['label'] = $carrier['name'] . ' - ' . $carrier['delay'] . ' - ' . $carrier['price'];
}
// If carrier related to a module, check for additionnal data to display
$carrier['extraContent'] = '';
if ($carrier['is_module']) {
if ($moduleId = Module::getModuleIdByName($carrier['external_module_name'])) {
// Hook called only for the module concerned
$carrier['extraContent'] = Hook::exec('displayCarrierExtraContent', ['carrier' => $carrier], $moduleId);
}
}
$carriers_available[$id_carriers_list] = $carrier;
}
}
}
}
}
return $carriers_available;
}
}