Jump to content

Add to basket and Buy now buttons?


Kristoff

Recommended Posts

Say for example you have the store set up to immediately go to the basket when you click to buy an item, is there a way of adding another button to add the item to the basket? Bypassing the set system for the store thus enabling a "Buy Now" and "Add to Basket" button?

Many thanks in advance

Link to comment
Share on other sites

I can look to find out how to do that.

 

One button behaves as if the store is set to keep the customer where he is, and the next button behaves as if the store is set to take the customer to the View Basket page?

 

Spot on. I did ask in a support ticket but didn't even get a reply. Would be great if you can investigate. Cheers!

Link to comment
Share on other sites

There are two places that need editing: /classes/cart.class.php, line 253 (deals with where to go after adding a gift certificate to the basket) and 405 (deals with where to go after adding an inventory item to the basket).

 

Of the two statements, there is a common part, with other stuff before and after it.

($GLOBALS['config']->get('config', 'basket_jump_to')) ? $GLOBALS['rootRel'].'index.php?_a=basket' : currentPage(null)

 

And of that, we will just change this part:

($GLOBALS['config']->get('config', 'basket_jump_to'))

 

to:

(!isset($_POST['stay']))

 

So, instead of using the store setting, we will use a key in the POSTed form array. If the POST array has ['stay'], we know to stay on this page.

 

Using the Kurouto template file content.homepage.php, find:

<input type="submit" value="{$LANG.catalogue.add_to_basket}" class="button_white" />

 

Make it look like:

<input onclick="this.name='cart';submit();" value="{$LANG.catalogue.add_to_basket}" class="button_white" />

<input onclick="this.name='stay';submit();" value="Add &amp; Remain" class="button_white" />

jQuery serializes to POST all the form's elements, except the submit-type element. But that's what we need. So we won't type these <input> elements as submit -- we won't type them as anything! (You might be able to use a <button>.) We also won't give them a name as only named elements will be serialized.

 

What we will do is that, when clicked, we give them a name and fire the DOM's form submit function, which jQuery catches. And the name of the element gets serialized. We don't care about the value the <input> sends back - only the name/key - as the value will change when the store's language changes.
 

Now that 'cart' or 'stay' will show up in POST, we can test for 'stay'.

Link to comment
Share on other sites

That worked perfectly thank you. I had a bit of a shuffle, as I don't use buy buttons on the homepage, but a More Info button, I added the code to the product page itself and as i'm not sure if there would be any issue with it, but I only needed to use the <input onclick="this.name='stay';submit();" value="Add &amp; Remain" class="button_white" /> button, I found it added a load of extra space to the button for some reason, but the original  <input type="submit" value="{$LANG.catalogue.buy}"> button works fine for going direct to the basket upon adding.

 

Many thanks again!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...