Post by cau96176 » Tue Jun 16, 2020 7:09 pm

I have been searching the forum looking for some help adding a 2nd Add to Cart button.

I have copied the code including the Quantity and pasted the code before the original one.
What happens is the following:

The new codes Quantity amount doesn't take effect, but whatever is typed in the original box is recorded.
The new codes Add to Cart button, changes to loading then adds the item to the cart but the old Add to Cart button does nothing.

Any ideas would be great.

Cheers!
Last edited by cau96176 on Fri Jun 19, 2020 7:17 am, edited 1 time in total.

New member

Posts

Joined
Sat Feb 01, 2014 11:51 pm

Post by straightlight » Tue Jun 16, 2020 7:42 pm

I have copied the code
What code?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by thekrotek » Tue Jun 16, 2020 7:51 pm

Of course, you can't just copy the code and don't change anything. What you have is absolutely valid result.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by cau96176 » Wed Jun 17, 2020 5:10 am

straightlight wrote:
Tue Jun 16, 2020 7:42 pm

What code?
Sorry that was a bit lazy of me.

I copied the code in the template file
/theme/default/template/product/product.tpl

I have tried the whole div product section, then I've tried the quantity and button only code.

Mainly this code

Code: Select all

 <div class="form-group">
              <label class="control-label" for="input-quantity"><b><?php echo $entry_qty; ?></b></label>
              <input type="text" name="quantity" value="<?php echo $minimum; ?>" size="2" id="input-quantity" class="form-control" style="width: 25%;" />
              <input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
              <br />
	      <ul style="list-style-type: none;margin: 0;padding: 0;">
              <li style="display: grid;"><button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary btn-lg btn-block"><?php echo $button_cart; ?></button></li>
Cheers
Last edited by straightlight on Wed Jun 17, 2020 5:27 am, edited 1 time in total.
Reason: Added code tags.

New member

Posts

Joined
Sat Feb 01, 2014 11:51 pm

Post by cau96176 » Wed Jun 17, 2020 5:15 am

thekrotek wrote:
Tue Jun 16, 2020 7:51 pm
Of course, you can't just copy the code and don't change anything. What you have is absolutely valid result.
I agree completely thekrotek, I now understand that I can duplicate simple href buttons to my hearts content all over the place as many times as I want,

along with php echo any number of time

...... But I was looking for a pointer for the duplicate Add to Cart button like.... Do I need to setup a new Add to Cart2 id and script to match or is there something else I need to look at.

Thanks.

New member

Posts

Joined
Sat Feb 01, 2014 11:51 pm

Post by cau96176 » Fri Jun 19, 2020 7:15 am

Found my answer in an old opencart version 1 general support post

viewtopic.php?t=118405

Gave the second button a unique id, like "button-cart2" and change the jquery to $('#button-cart,#button-cart2').bind('click', function() {

Can't believe how straight forward that was!

New member

Posts

Joined
Sat Feb 01, 2014 11:51 pm
Who is online

Users browsing this forum: No registered users and 104 guests