Patch (to be ported)
Project:
Ubercart pictured cart block
Version:
6.x-1.0-beta3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Mar 2010 at 14:22 UTC
Updated:
22 Mar 2010 at 14:22 UTC
I ran into problems when I used this module with Product Minimum / Maximum ( http://drupal.org/project/uc_product_minmax ), in that when I tried to decrement or increment the contents of my cart, it only did it by one, which is not allowed if you must have multiples of more than 1 for a product. I've hacked the pictured cart module to work for me, and I share my 10 lines of code that fixes this issue. I haven't tested it on anything other than my site, so no guarantees that it will work.
in uc_pic_cart_block.module , replace the uc_pic_cart_block_updateproduct_submit() function (around line 200 onwards) with the following code.
/**
* Implementation of submit function for update product forms.
*
* @ingroup forms
* @see uc_pic_cart_block_updateproduct_form()
*/
function uc_pic_cart_block_updateproduct_submit($form, &$form_state) {
$module = $form_state['values']['uc_pic_cart_block_updateform_module'];
$id = $form_state['values']['uc_pic_cart_block_updateform_nid'];
$data = unserialize($form_state['values']['uc_pic_cart_block_updateform_itemdata']);
$count = $form_state['values']['uc_pic_cart_block_updateform_count'];
$adding = $form_state['values']['uc_pic_cart_block_updateform_adding'];
// Check for product minimum multiples, in which case add / subtract by multiple
if (!$node) {
$node = node_load($id);
}
if (!$node->pmin_multiple || $node->pmin_multiple != '') {
if ($adding) {
$adding = $node->pmin_multiple * $adding;
}
if ($count) {
$count = $count - $node->pmin_multiple + 1;
}
}
// Standart functions are the best way to update cart item :)
if ($adding) {
$kit_products = array();
// Adding product kit elements with current attributes
foreach ($data as $element) {
if (is_object($element)) {
if ($element->module == 'uc_product_kit') {
$kit_products['products'][$element->nid]['nid'] = $element->nid;
if (isset($element->data['attributes']) && !empty($element->data['attributes'])) {
$kit_products['products'][$element->nid]['attributes'] = $element->data['attributes'];
}
}
}
}
uc_cart_add_item($id, $adding, $data + $kit_products);
}
else {
module_invoke($module, 'update_cart_item', $id, $data, $count);
}
}