// Context part 17
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7688 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user