disable cart quantity, every product listed

  • Posts: 73
  • Thank you received: 1
11 years 4 months ago #112148

Is there a way to separate the same product with different characteristics in the cart? Lets say I have ProductA with characteristics 1-10. So ProductA_1 ProductA_2 ProductA_3 will all be listed under ProductA with quantity 3 in the cart module and in the checkout. Any way to separate them? Not afraid of doing some php

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
11 years 4 months ago #112151

Hi,

I didn't totally understood what you want to do, can you show it to me with some screenshots for example ?

Please Log in or Create an account to join the conversation.

  • Posts: 73
  • Thank you received: 1
11 years 4 months ago #112152

I figured out what's going on. It's a bug that is causing this. I'm using a characteristic override and apparently the characteristic is not submitted. Firebug throws a javascript error.

This is the site:
exo-l.com/shop2/exo-l

If you change the colors firebug throws this error:

TypeError: form.elements is undefined

var checkFields = form.elements['hikashop_product_characteristic['+options[i]+']'];
Inside the function hikashopUpdateVariant()

In the override i made these 2 changes (I added comments to the lines i changed):
Original
case 'dropdown':
            $main_html = '<table class="hikashop_product_characteristics_table">';
            $config = & hikashop_config();
            foreach ($obj->characteristics as $characteristic) {
                $main_html.='<tr>';
                $values = array();
                if (!empty($characteristic->values)) {
                    foreach ($characteristic->values as $k => $value) {
                        if (!$config->get('show_out_of_stock')) {
                            $hasQuantity = false;
                            foreach ($element->variants as $variant) {
                                foreach ($variant->characteristics as $variantCharacteristic) {
                                    if ($variantCharacteristic->characteristic_id == $value->characteristic_id) {
                                        if ($variant->product_quantity != 0) {
                                            $hasQuantity = true;
                                        }
                                    }
                                }
                            }
                            if (!$hasQuantity)
                                continue;
                        }
                        $values[$k] = $value->characteristic_value; //THIS LINE
                    }
                }
                $html = $obj->display($characteristic->characteristic_id, @$characteristic->default->characteristic_id, $values, $params->get('characteristic_display')); //THIS LINE
                if ($params->get('characteristic_display_text')) {
                    $html = $characteristic->characteristic_value . '</td><td>' . $html;
                }
                $main_html.='<td>' . $html . '</td></tr>';
            }

Modified
case 'dropdown':
            $main_html = '<table class="hikashop_product_characteristics_table">';
            $config = & hikashop_config();
            foreach ($obj->characteristics as $characteristic) {
                $main_html.='<tr>';
                $values = array();
                if (!empty($characteristic->values)) {
                    foreach ($characteristic->values as $k => $value) {
                        if (!$config->get('show_out_of_stock')) {
                            $hasQuantity = false;
                            foreach ($element->variants as $variant) {
                                foreach ($variant->characteristics as $variantCharacteristic) {
                                    if ($variantCharacteristic->characteristic_id == $value->characteristic_id) {
                                        if ($variant->product_quantity != 0) {
                                            $hasQuantity = true;
                                        }
                                    }
                                }
                            }
                            if (!$hasQuantity)
                                continue;
                        }
                        $values[$k] = '<img src="/media/exo_colors/' . $value->characteristic_value . '.png" id=' . $value->characteristic_value . ' />'; //THIS LINE
                    }
                }
                $html = $obj->display($characteristic->characteristic_id, @$characteristic->default->characteristic_id, $values, $characteristic->characteristic_value, $params->get('characteristic_display')); //THIS LINE
                if ($params->get('characteristic_display_text')) {
                    $html = $characteristic->characteristic_value . '</td><td>' . $html;
                }
                $main_html.='<td>' . $html . '</td></tr>';
            }

I also changed the display method in the characteristic.php file like this.
    function display($map, $value, $values, $customization, $characteristic_display = 'dropdown') {
        if (empty($values) || !is_array($values)) {
            return JText::_('NO_VALUES_FOUND');
        }
        if (is_array($this->characteristics)) {
            $characteristic_id = $map;
            $map = 'hikashop_product_characteristic[' . $characteristic_id . ']';
            $id = 'hikashop_product_characteristic_' . $characteristic_id;
        } else {
            $id = $map;
        }
        $this->values = array();
        foreach ($values as $key => $val) {
            if (strlen($val) != 0 && empty($val)) {
                $val = $val . '&nbsp;';
            }
            $this->values[] = JHTML::_('select.option', $key, $val);
        }
        if ($characteristic_display != 'radio') {
            $characteristic_display = 'generic';
        }
        $html = '<div id="' . strtolower($customization) . '">' . JHTML::_('select.' . $characteristic_display . 'list', $this->values, $map, 'class="inputbox" size="1"' . $this->options, 'value', 'text', (int) $value, $id) . '</div>';
        return $html;
    }

This is the full override file:
pastebin.com/LLwZgQ1j
Apparently the problem lies as soon as the display method is called with that extra parameter. Not sure what's going on exactly. I'm running on 1.6

Last edit: 11 years 4 months ago by Ortix.

Please Log in or Create an account to join the conversation.

  • Posts: 2334
  • Thank you received: 403
11 years 4 months ago #112226

Hello there,

Since your problem is linked with the modifications you made on the view we can't help you.
This support forum is more dedicated to core issues, we can't help everybody with their customization problems.
I hope you'll find a solution.

Please Log in or Create an account to join the conversation.

Time to create page: 0.079 seconds
Powered by Kunena Forum