// Context part 17
This commit is contained in:
@@ -30,9 +30,15 @@ define('PS_ADMIN_DIR', getcwd());
|
||||
include(PS_ADMIN_DIR.'/../config/config.inc.php');
|
||||
|
||||
/* Header can't be included, so cookie must be created here */
|
||||
$context = Context::getContext();
|
||||
|
||||
$cookie = new Cookie('psAdmin');
|
||||
if (!$cookie->id_employee)
|
||||
Tools::redirectAdmin('login.php');
|
||||
|
||||
$context->employee = new Employee($cookie->id_employee);
|
||||
$context->language = new Language($context->employee->id_lang);
|
||||
$context->country = $defaultCountry;
|
||||
|
||||
$functionArray = array(
|
||||
'pdf' => 'generateInvoicePDF',
|
||||
|
||||
@@ -258,10 +258,13 @@ class AdminCarts extends AdminTab
|
||||
|
||||
if (is_array($customizedDatas) AND isset($customizedDatas[(int)($product['id_product'])][(int)($product['id_product_attribute'])]))
|
||||
{
|
||||
$image = new Image($image['id_image']);
|
||||
if (isset($image['id_image']))
|
||||
$image = new Image($image['id_image']);
|
||||
else
|
||||
$image = new Image();
|
||||
echo '
|
||||
<tr>
|
||||
<td align="center">'.(isset($image['id_image']) ? cacheImage(_PS_IMG_DIR_.'p/'.$image->getExistingImgPath().'.jpg',
|
||||
<td align="center">'.($image->id ? cacheImage(_PS_IMG_DIR_.'p/'.$image->getExistingImgPath().'.jpg',
|
||||
'product_mini_'.(int)($product['id_product']).(isset($product['id_product_attribute']) ? '_'.(int)($product['id_product_attribute']) : '').'.jpg', 45, 'jpg') : '--').'</td>
|
||||
<td><a href="index.php?tab=AdminCatalog&id_product='.$product['id_product'].'&updateproduct&token='.$tokenCatalog.'">
|
||||
<span class="productName">'.$product['name'].'</span><br />
|
||||
|
||||
@@ -32,6 +32,7 @@ class AdminShipping extends AdminTab
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$this->table = 'delivery';
|
||||
$this->_fieldsHandling = array(
|
||||
'PS_SHIPPING_HANDLING' => array('title' => $this->l('Handling charges'), 'suffix' => $context->currency, 'validation' => 'isPrice', 'cast' => 'floatval'),
|
||||
@@ -189,6 +190,7 @@ class AdminShipping extends AdminTab
|
||||
|
||||
public function displayFormFees()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$carrierArray = array();
|
||||
$id_carrier = Tools::getValue('id_carrier');
|
||||
$carriers = Carrier::getCarriers(Configuration::get('PS_LANG_DEFAULT'), true , false,false, NULL, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
|
||||
|
||||
+4
-3
@@ -545,7 +545,6 @@ class CartCore extends ObjectModel
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$quantity = (int)$quantity;
|
||||
$id_product = (int)$id_product;
|
||||
$id_product_attribute = (int)$id_product_attribute;
|
||||
@@ -1590,6 +1589,8 @@ class CartCore extends ObjectModel
|
||||
* Return custom pictures in this cart for a specified product
|
||||
*
|
||||
* @param int $id_product
|
||||
* @param int $type only return customization of this type
|
||||
* @param bool $not_in_cart only return customizations that are not in cart already
|
||||
* @return array result rows
|
||||
*/
|
||||
public function getProductCustomization($id_product, $type = null, $not_in_cart = false)
|
||||
@@ -1600,8 +1601,8 @@ class CartCore extends ObjectModel
|
||||
ON cu.`id_customization` = cd.`id_customization`
|
||||
WHERE cu.id_cart = '.(int)$this->id.'
|
||||
AND cu.id_product = '.(int)$id_product.
|
||||
($type == 0 ? ' AND type = 0' : '').
|
||||
($type == 1 ? ' AND type = 1' : '').
|
||||
($type === _CUSTOMIZE_FILE_ ? ' AND type = '.(int)_CUSTOMIZE_FILE_ : '').
|
||||
($type === _CUSTOMIZE_TEXTFIELD_ ? ' AND type = '.(int)_CUSTOMIZE_TEXTFIELD_ : '').
|
||||
($not_in_cart ? ' AND in_cart = 0' : '')
|
||||
);
|
||||
return $result;
|
||||
|
||||
+8
-5
@@ -3092,13 +3092,16 @@ class ProductCore extends ObjectModel
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$fields = array_merge($context->cookie->getFamily('pictures_'.(int)($this->id)), $context->cookie->getFamily('textFields_'.(int)($this->id)));
|
||||
$fields = $context->cart->getProductCustomization($this->id, null, true);
|
||||
if (($requiredFields = $this->getRequiredCustomizableFields()) === false)
|
||||
return false;
|
||||
$prefix = array(_CUSTOMIZE_FILE_ => 'pictures_'.(int)($this->id).'_', _CUSTOMIZE_TEXTFIELD_ => 'textFields_'.(int)($this->id).'_');
|
||||
foreach ($requiredFields AS $field)
|
||||
if (!isset($fields[$prefix[$field['type']].$field['id_customization_field']]) OR empty($fields[$prefix[$field['type']].$field['id_customization_field']]))
|
||||
return false;
|
||||
|
||||
$fields_present = array();
|
||||
foreach ($fields as $field)
|
||||
$fields_present[] = array('id_customization_field' => $field['index'], 'type' => $field['type']);
|
||||
foreach ($requiredFields AS $required_field)
|
||||
if (!in_array($required_field, $fields_present))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +172,7 @@ class CartControllerCore extends FrontController
|
||||
if ($context->cart->id)
|
||||
$context->cookie->id_cart = (int)$context->cart->id;
|
||||
}
|
||||
|
||||
if ($add AND !$producToAdd->hasAllRequiredCustomizableFields() AND !$customizationId)
|
||||
$this->errors[] = Tools::displayError('Please fill in all required fields, then save the customization.');
|
||||
if (!sizeof($this->errors))
|
||||
|
||||
@@ -489,6 +489,7 @@ CREATE TABLE `PREFIX_customization` (
|
||||
`quantity` int(10) NOT NULL,
|
||||
`quantity_refunded` INT NOT NULL DEFAULT '0',
|
||||
`quantity_returned` INT NOT NULL DEFAULT '0',
|
||||
`in_cart` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id_customization`,`id_cart`,`id_product`),
|
||||
KEY `id_product_attribute` (`id_product_attribute`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
@@ -300,8 +300,10 @@ CREATE TABLE `PREFIX_referrer_shop` (
|
||||
INSERT INTO `PREFIX_referrer_shop` (`id_referrer`, `id_shop`) SELECT `id_referrer`, 1 FROM `PREFIX_referrer`;
|
||||
ALTER TABLE `PREFIX_referrer` DROP `cache_visitors`, DROP `cache_visits`, DROP `cache_pages`, DROP `cache_registrations`, DROP `cache_orders`, DROP `cache_sales`, DROP `cache_reg_rate`, DROP `cache_order_rate`;
|
||||
|
||||
ALTER TABLE PREFIX_employee ADD `show_screencast` tinyint(1) unsigned NOT NULL default '1';
|
||||
ALTER TABLE `PREFIX_employee` ADD `show_screencast` TINYINT(1) UNSIGNED NOT NULL default '1';
|
||||
|
||||
ALTER TABLE `PREFIX_cart_product` ADD `id_shop` INT NOT NULL DEFAULT '1' AFTER `id_product`;
|
||||
|
||||
ALTER TABLE `PREFIX_customization` ADD `in_cart` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0';
|
||||
|
||||
/* PHP:create_multistore(); */
|
||||
|
||||
Reference in New Issue
Block a user