0

I'm using J2Store and would like to display a "quantity input" and an "add to cart button" for each product option so that I can get rid of the radio button completely. This way, clicking the add to cart button will indicate that that product option is selected, instead of clicking a radio button and then the add to cart button.

Right now I have the elements added to each option line, but they aren't functioning properly. If I input a quantity other than "1" it still only adds one item to the cart. Attached is a screenshot of what I have so far.

As per @Lodder 's request, here is the relevant code from my addtocart_option.php file:

<?php if ($option['type'] == 'radio') { ?>
            <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
                <?php if ($option['required']) { ?>
                    <span class="required">*</span>
                <?php } ?>
                <b><?php echo $option['option_name']; ?>:</b><br />
                <?php foreach ($option['optionvalue'] as $option_value) { ?> <!--loop through product options-->
                    <div class="option-line"><!--HEYOOO! HERE'S YOUR PRODUCT OPTION LINE!-->
                        <label for="option-value-<?php echo $option_value['product_optionvalue_id']; ?>"><?php echo $option_value['optionvalue_name']; ?>
                        <!--TAX STUFF, DON'T TOUCH!-->
                        <?php if ($option_value['product_optionvalue_price'] > 0) { ?>
                            <?php $tax = $this->tax_class->getProductTax($option_value['product_optionvalue_price'], $this->item->product_id); ?>
                            <?php  echo J2StoreHelperCart::dispayPriceWithTax($option_value['product_optionvalue_price'], $tax, $this->params->get('price_display_options', 1)); ?>
                        <?php } ?>
                        <!--/TAX STUFF-->
                        </label>

                        <input <?php echo $checked; ?> 
                        type="radio" 
                        name="product_option[<?php echo $option['product_option_id']; ?>]" 
                        value="<?php echo $option_value['product_optionvalue_id']; ?>" 
                        id="option-value-<?php echo $option_value['product_optionvalue_id']; ?>" 
                        />
                        <!--QUANTITY INPUT FOR OPTION-->
                        <div id='product_quantity_input_<?php echo $item->product_id; ?>' class="product_quantity_input">

                            <input 
                            type="text" 
                            name="product_qty" 
                            value="<?php echo $item->product_quantity; ?>" 
                            size="3" 
                            />
                            <?php if(isset($item->item_minimum_notice)):?>
                                <br />
                                <small class="j2store-minmum-quantity muted"><?php echo $item->item_minimum_notice; ?></small>
                            <?php endif; ?>
                        </div><!--/"product_quantity_input"-->

                        <!--ADD TO CART BUTTON FOR OPTION VALUE-->
                        <div id='add_to_cart_<?php echo $item->product_id; ?>' class="j2store_add_to_cart" style="display: block;">
                            <input 
                            type="hidden" 
                            id="j2store_product_id" 
                            name="product_id" 
                            value="<?php echo $option_value['product_optionvalue_id']; ?>" 
                            />
                            <?php echo JHTML::_( 'form.token' ); ?>

                            <input 
                            type="hidden" 
                            name="return" 
                            value="<?php echo base64_encode( JUri::getInstance()->toString() ); ?>" 
                            />

                            <input 
                            type="submit" 
                            name="product_option[<?php echo $option['product_option_id']; ?>]"
                            value="+" 
                            class="j2store_cart_button btn btn-primary" 
                            id="option-value-<?php echo $option_value['product_optionvalue_id']; ?>" 
                            />
                        </div><!--/"add_to_cart"-->
                    </div><!--/"option-line"-->

            <?php } ?>
            </div><!--/"option"-->
        <?php } ?>

Any help or suggestions would be most appreciated!

product screenshot

4
  • Can you please show the code you're using?
    – Lodder
    Sep 22, 2014 at 16:09
  • @Lodder, I've added the section of code I'm working on in addtocart_options.php. Haven't changed anything in addtocart.php yet.
    – Annemarie
    Sep 22, 2014 at 16:34
  • Have you contacted the developers?
    – jonboy
    Sep 23, 2014 at 7:21
  • I have, @johnny_s, and posted in their community forum as well. Hoping I'll get an answer/help soon :/
    – Annemarie
    Sep 23, 2014 at 13:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.