Note that there are some explanatory texts on larger screens.

plurals
  1. POOpencart how to add product options into a tab
    primarykey
    data
    text
    <p>Opencart 1.5.3. Im trying to get the product options on the page to be displayed inside a tab. If I use the following code I get no errors and it looks fine, but clicking add to cart does nothing. If the code is outside the tab it works fine. Im not sure what Im doing wrong.</p> <pre><code>&lt;div id="tabs_container"&gt; &lt;ul id="tabs"&gt; &lt;li class="active"&gt;&lt;a href="#tab1"&gt;tab1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#tab2"&gt;tab2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#tab3"&gt;tab3&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#tab4"&gt;tab4&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div id="tabs_content_container"&gt; &lt;div id="tab1" class="tab_content" style="display:block"&gt;&lt;/div&gt;&lt;!--tab1--&gt; &lt;div id="tab2" class="tab_content"&gt;&lt;/div&gt;&lt;!--tab2--&gt; &lt;div id="tab3" class="tab_content"&gt;&lt;/div&gt;&lt;!--tab3--&gt; &lt;div id="tab4" class="tab_content"&gt; &lt;?php if ($options) { ?&gt; &lt;div class="options"&gt; &lt;h2&gt;&lt;?php echo $text_option; ?&gt;&lt;/h2&gt; &lt;br /&gt; &lt;?php foreach ($options as $option) { ?&gt; &lt;?php if ($option['type'] == 'select') { ?&gt; &lt;div id="option-&lt;?php echo $option['product_option_id']; ?&gt;" class="option"&gt; &lt;?php if ($option['required']) { ?&gt; &lt;span class="required"&gt;*&lt;/span&gt; &lt;?php } ?&gt; &lt;b&gt;&lt;?php echo $option['name']; ?&gt;:&lt;/b&gt;&lt;br /&gt; &lt;select name="option[&lt;?php echo $option['product_option_id']; ?&gt;]"&gt; &lt;option value=""&gt;&lt;?php echo $text_select; ?&gt;&lt;/option&gt; &lt;?php foreach ($option['option_value'] as $option_value) { ?&gt; &lt;option value="&lt;?php echo $option_value['product_option_value_id']; ?&gt;"&gt;&lt;?php echo $option_value['name']; ?&gt; &lt;?php if ($option_value['price']) { ?&gt; (&lt;?php echo $option_value['price_prefix']; ?&gt;&lt;?php echo $option_value['price']; ?&gt;) &lt;?php } ?&gt; &lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; &lt;/div&gt; &lt;br /&gt; &lt;?php } ?&gt; &lt;?php } ?&gt; &lt;/div&gt; &lt;/div&gt;&lt;!--tab4--&gt; &lt;/div&gt;&lt;!--tabs_content_container--&gt; </code></pre> <p>Here is the javascript for the form submit that Opencart uses.</p> <pre><code>&lt;script type="text/javascript"&gt;&lt;!-- $('#button-cart').bind('click', function() { $.ajax({ url: 'index.php?route=checkout/cart/add', type: 'post', data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'), dataType: 'json', success: function(json) { $('.success, .warning, .attention, information, .error').remove(); if (json['error']) { if (json['error']['option']) { for (i in json['error']['option']) { $('#option-' + i).after('&lt;span class="error"&gt;' + json['error']['option'][i] + '&lt;/span&gt;'); } } } if (json['success']) { $('#notification').html('&lt;div class="success" style="display: none;"&gt;' + json['success'] + '&lt;img src="catalog/view/theme/default/image/close.png" alt="" class="close" /&gt;&lt;/div&gt;'); $('.success').fadeIn('slow'); $('#cart-total').html(json['total']); $('html, body').animate({ scrollTop: 0 }, 'slow'); } } }); }); //--&gt;&lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload