first commit

This commit is contained in:
2024-10-25 14:16:28 +02:00
commit 925276dbb2
33795 changed files with 4780077 additions and 0 deletions

View File

@@ -0,0 +1,174 @@
<?php
/**
* File from http://PrestaShow.pl
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future.
*
* @authors PrestaShow.pl <kontakt@prestashow.pl>
* @copyright 2015 PrestaShow.pl
* @license http://PrestaShow.pl/license
*/
class Carrier extends CarrierCore
{
public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null, &$error = array())
{
require_once _PS_MODULE_DIR_ . '/pshowimporter/config.php';
static $ps_country_default = null;
if ($ps_country_default === null) {
$ps_country_default = Configuration::get('PS_COUNTRY_DEFAULT');
}
if (is_null($id_shop)) {
$id_shop = Context::getContext()->shop->id;
}
if (is_null($cart)) {
$cart = Context::getContext()->cart;
}
if (is_null($error) || !is_array($error)) {
$error = array();
}
$id_address = (int) ((!is_null($id_address_delivery) && $id_address_delivery != 0) ? $id_address_delivery : $cart->id_address_delivery);
if ($id_address) {
$id_zone = Address::getZoneById($id_address);
// Check the country of the address is activated
if (!Address::isCountryActiveById($id_address)) {
return array();
}
} else {
$country = new Country($ps_country_default);
$id_zone = $country->id_zone;
}
// Does the product is linked with carriers?
$cache_id = 'Carrier::getAvailableCarrierList_' . (int) $product->id . '-' . (int) $id_shop;
if (!Cache::isStored($cache_id)) {
$query = new DbQuery();
$query->select('id_carrier');
$query->from('product_carrier', 'pc');
$query->innerJoin(
'carrier', 'c', 'c.id_reference = pc.id_carrier_reference AND c.deleted = 0 AND c.active = 1'
);
$query->where('pc.id_product = ' . (int) $product->id);
$query->where('pc.id_shop = ' . (int) $id_shop);
$carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
Cache::store($cache_id, $carriers_for_product);
} else {
$carriers_for_product = Cache::retrieve($cache_id);
}
$carrier_list = array();
if (!empty($carriers_for_product)) {
//the product is linked with carriers
foreach ($carriers_for_product as $carrier) { //check if the linked carriers are available in current zone
if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone)) {
$carrier_list[$carrier['id_carrier']] = $carrier['id_carrier'];
}
}
if (empty($carrier_list)) {
return array();
}//no linked carrier are available for this zone
}
// The product is not dirrectly linked with a carrier
// Get all the carriers linked to a warehouse
if ($id_warehouse) {
$warehouse = new Warehouse($id_warehouse);
$warehouse_carrier_list = $warehouse->getCarriers();
}
$available_carrier_list = array();
$cache_id = 'Carrier::getAvailableCarrierList_getCarriersForOrder_' . (int) $id_zone . '-' . (int) $cart->id;
if (!Cache::isStored($cache_id)) {
$customer = new Customer($cart->id_customer);
$carrier_error = array();
$carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups(), $cart, $carrier_error);
Cache::store($cache_id, array($carriers, $carrier_error));
} else {
list($carriers, $carrier_error) = Cache::retrieve($cache_id);
}
$error = array_merge($error, $carrier_error);
foreach ($carriers as $carrier) {
$available_carrier_list[$carrier['id_carrier']] = $carrier['id_carrier'];
}
if ($carrier_list) {
$carrier_list = array_intersect($available_carrier_list, $carrier_list);
} else {
$carrier_list = $available_carrier_list;
}
if (isset($warehouse_carrier_list)) {
$carrier_list = array_intersect($carrier_list, $warehouse_carrier_list);
}
$cart_quantity = 0;
$cart_weight = 0;
foreach ($cart->getProducts(false, false) as $cart_product) {
if ($cart_product['id_product'] == $product->id) {
$cart_quantity += $cart_product['cart_quantity'];
}
if (isset($cart_product['weight_attribute']) && $cart_product['weight_attribute'] > 0) {
$cart_weight += ($cart_product['weight_attribute'] * $cart_product['cart_quantity']);
} else {
$cart_weight += ($cart_product['weight'] * $cart_product['cart_quantity']);
}
// ADDED BY PSHOWIMPORTER for combination dimensions
if (!PShow_Settings::getInstance(_PS_MODULE_DIR_ . 'pshowimporter/pshowimporter.php')->get('mod_combination_dimensions')) {
continue;
}
if ($product->reference == $cart_product['reference']) {
continue;
}
$combination = new Combination((int) $cart_product['id_product_attribute']);
if ($combination->width > 0) {
$product->width = $combination->width;
}
if ($combination->height > 0) {
$product->height = $combination->height;
}
if ($combination->depth > 0) {
$product->depth = $combination->depth;
}
// / ADDED BY PSHOWIMPORTER for combination dimensions
}
if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0 || $cart_weight > 0) {
foreach ($carrier_list as $key => $id_carrier) {
$carrier = new Carrier($id_carrier);
// Get the sizes of the carrier and the product and sort them to check if the carrier can take the product.
$carrier_sizes = array((int) $carrier->max_width, (int) $carrier->max_height, (int) $carrier->max_depth);
$product_sizes = array((int) $product->width, (int) $product->height, (int) $product->depth);
rsort($carrier_sizes, SORT_NUMERIC);
rsort($product_sizes, SORT_NUMERIC);
if (($carrier_sizes[0] > 0 && $carrier_sizes[0] < $product_sizes[0]) || ($carrier_sizes[1] > 0 && $carrier_sizes[1] < $product_sizes[1]) || ($carrier_sizes[2] > 0 && $carrier_sizes[2] < $product_sizes[2])) {
$error[$carrier->id] = Carrier::SHIPPING_SIZE_EXCEPTION;
unset($carrier_list[$key]);
}
if ($carrier->max_weight > 0 && ($carrier->max_weight < $product->weight * $cart_quantity || $carrier->max_weight < $cart_weight)) {
$error[$carrier->id] = Carrier::SHIPPING_WEIGHT_EXCEPTION;
unset($carrier_list[$key]);
}
}
}
return $carrier_list;
}
}

View File

@@ -0,0 +1,22 @@
<?php
/**
* File from http://PrestaShow.pl
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future.
*
* @authors PrestaShow.pl <kontakt@prestashow.pl>
* @copyright 2015 PrestaShow.pl
* @license http://PrestaShow.pl/license
*/
class Combination extends CombinationCore
{
public $description;
public $width;
public $height;
public $depth;
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* File from http://PrestaShow.pl
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future.
*
* @authors PrestaShow.pl <kontakt@prestashow.pl>
* @copyright 2015 PrestaShow.pl
* @license http://PrestaShow.pl/license
*/
class Product extends ProductCore
{
/** @var boolean */
public $import = true;
public static function checkImportStatus($id_product, $id_shop)
{
if (version_compare(_PS_VERSION_, '1.7') >= 0) {
return 1;
}
$q = "SELECT `import` FROM `" . _DB_PREFIX_ . "product_shop` WHERE `id_product` = " . (int) $id_product . " AND `id_shop` = " . (int) $id_shop;
return (int) Db::getInstance()->getValue($q);
}
public static function priceCalculation($id_shop, $id_product, $id_product_attribute, $id_country, $id_state, $zipcode, $id_currency, $id_group, $quantity, $use_tax, $decimals, $only_reduc, $use_reduc, $with_ecotax, &$specific_price, $use_group_reduction, $id_customer = 0, $use_customer_price = true, $id_cart = 0, $real_quantity = 0, $id_customization = 0)
{
if (version_compare(_PS_VERSION_, '1.7') == -1) {
$price = parent::priceCalculation($id_shop, $id_product, $id_product_attribute, $id_country, $id_state, $zipcode, $id_currency, $id_group, $quantity, $use_tax, $decimals, $only_reduc, $use_reduc, $with_ecotax, $specific_price, $use_group_reduction, $id_customer, $use_customer_price, $id_cart, $real_quantity);
} else {
$price = parent::priceCalculation($id_shop, $id_product, $id_product_attribute, $id_country, $id_state, $zipcode, $id_currency, $id_group, $quantity, $use_tax, $decimals, $only_reduc, $use_reduc, $with_ecotax, $specific_price, $use_group_reduction, $id_customer, $use_customer_price, $id_cart, $real_quantity, $id_customization);
}
require_once _PS_MODULE_DIR_ . '/pshowimporter/config.php';
if ((bool) PShow_Settings::getInstance(_PS_MODULE_DIR_ . 'pshowimporter/')->get('mod_combination_nett_price') === false) {
return $price;
}
static $address = null;
static $context = null;
if ($address === null) {
$address = new Address();
}
if ($context == null) {
$context = Context::getContext()->cloneContext();
}
$address->id_country = $id_country;
$address->id_state = $id_state;
$address->postcode = $zipcode;
$tax_manager = TaxManagerFactory::getManager($address, Product::getIdTaxRulesGroupByIdProduct((int) $id_product, $context));
$product_tax_calculator = $tax_manager->getTaxCalculator();
$p = new Product($id_product);
$pPrice = $use_tax ? $product_tax_calculator->addTaxes($p->price) : $p->price;
$price = $price - $pPrice;
return $price;
}
}