// Context part 17

This commit is contained in:
tDidierjean
2011-07-22 09:35:28 +00:00
parent 3f9a9e41d7
commit 112b465f96
8 changed files with 30 additions and 11 deletions
+4 -3
View File
@@ -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
View File
@@ -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;
}