Jump to content

Linking Add to Basket to Cart


Guest paulabakerparkin

Recommended Posts

Guest paulabakerparkin

Hello,

I am losing sales due to customers not noticing that when they clicked 'add to basket' the product has actually added to the basket.

Is there a way to have it that when the customer click 'add to basket' they are automatically sent to the 'view cart' page?

I know that it updates in the shopping cart box, but my customers aren't figuring it out!

Can anybody help me...I will pay if needs be!

Paula

Link to post
Share on other sites

-----------------------------------------------------------

We interrupt this thread to make the following public service announcement:

SOLUTION POSTED HERE

Thanks, Estelle!

Carry On! ;)

-----------------------------------------------------------

Hi Paula,

That link is controlled by javascript in your_skin_file/styleTemplates/content/viewCat.tpl, so it should be very simple matter to do what you ask.

Open the file, and look for the comment <!-- BEGIN: buy_btn --> (around line 38 in Classic skin).

There are a couple of lines of code between that comment and this closing comment, <!-- END: buy_btn --> containing a link that looks like this:

href="java script:submitDoc('prod{PRODUCT_ID}');"

AFTER the semi-colon, and BEFORE the double-quote, add this:

[Edit: This code has now been corrected for an errant colon]

location='cart.php?act={CART_STEP}';

so it now looks like this:

href="java script:submitDoc('prod{PRODUCT_ID}');location='cart.php?act={CART_STEP}';"

That's it. :w00t:

Link to post
Share on other sites

Paula, thanks for the link. Evidently, though, you moved the javascript snippet that I gave you back out of the file by the time I saw your page. When I view the source, the code that I gave you isn't there; furthermore, I find two "Add to Basket" buttons on your page.

#1 <p align="right"><a href="java script:submitDoc('addtobasket');"><font color="#333333"><img height="44" alt="" src="http://www.prettypebbles.co.uk/pbstore1/images/uploads/abbutton.gif" width="90" border="0"/></font></a></p>

#2 <a href="java script:submitDoc('addtobasket');" class="txtButton">Add to Basket</a></span></span></p></td>

But the main reason that my code didn't work properly is that I mistyped it - I used a colon where I should have used an equal sign ;) should be location= not location:

Try making your javascript look like this in both instances:

href="java script:submitDoc('addtobasket');location='cart.php?act=cart';"

I'm sorry about the earlier mistake; this should work for you. If it doesn't, and you want me to actually work on and fix the problem for you, I will give you a 50% discount on the services required B)

Link to post
Share on other sites

Of subject and in reply to the last post nice skin... I would like to add that i am being redirected to the cart, the first time however i was taken to an empty cart and the second time i was taken to the cart as intended with the item in...

Dont understand this fully...

But AGAIN Very nice store...

Link to post
Share on other sites

Marks i would like to ask why you made a second alteration to the code you suplied...

First

href="javascript:submitDoc('prod{PRODUCT_ID}');location:'cart.php?act={CART_STEP}';"



then you said to change the : to an = but your second code was 
href="javascript:submitDoc('addtobasket');location='cart.php?act=cart';"



Why did you use {CART_STEP} in the first snip and cart in the second?



is it ment to be 


href="javascript:submitDoc('prod{PRODUCT_ID}');location='cart.php?act={CART_STEP}';"

???????????

Link to post
Share on other sites

Thanks for catching that - I didn't really think it should matter. "cart.php?act=cart" should take you to the cart alright, "cart.php?act={CART_STEP}" also takes you to the cart, but includes a variable that is meant to tell the cart which step of the checkout process you're on.

The link with the variable is the link that appears in styleTemplates/boxes/shoppingCart.tpl, and the other (act=cart) is the same link that appears elsewhere on the page that Paula was coding.

Evidently the javascript worked as expected in sending the viewer to the cart, but the submitDoc() function is not working properly in tandem with it. For this, I do not have a ready answer ;)

EDIT: I'm curious now, I'm going to experiment with this on a test store to see if I can find a solution. Meantime, I'd suggest that no one else should institute the code before I get it working . . .

Link to post
Share on other sites

OK, I've gone round and round and tried every way I can think of to make these methods work simultaneously on the onClick or href event with javascript . . . and I finally go it working, but it is only through a cludgy workaround.

I had to throw an alert method between the submitDoc and location methods. I couldn't find a way to make it work without doing this.

Good news is your customers will definitely know they've successfully added products. Bad news is that if your customers add quite alot of products, they will surely find the alerts annoying.

To see this at work at my test site, go here and add products to the cart:

http://allservico.com/skinTest/

If you really want this code, here it is; I added this to viewProd.tpl at the add to basket button . . .

<a href="javascript:submitDoc('addtobasket'); alert('This product will be added to your shopping cart.'); location('cart.php?act=cart')" class="txtButton">{BTN_ADDBASKET}</a>

Enjoy ;)

Link to post
Share on other sites

At the "add to basket" button code, there is this link:

<a href="javascript:submitDoc('addtobasket');" class="txtButton">{BTN_ADDBASKET}</a>



REPLACE with:




<a href="javascript:submitDoc('addtobasket'); alert('This product will be added to your shopping cart.'); location('cart.php?act=cart')" class="txtButton">{BTN_ADDBASKET}</a>

Link to post
Share on other sites

BAD NEWS -

Doesn't appear to work in Mozilla still ;)

Here's what I get with FF and ns, item is added and alert pops up, but you do not get sent to cart.

Sorry though, I can't work on this any more for awhile as I have a couple of commissions to work on. Perhaps a more knowledgeable scripter can fix what I could only rig up half-arse :huh:

Link to post
Share on other sites

@evilhomer - Reading 101

Read the whole thread and maybe you'll understand . . . look also at her site and you will see why customers need assurance that items are actually added when they click "Add to Basket."

My problems getting both location() and submitDoc() to work simultaneously on clicking the "Add to Basket" should be pretty clear above. What I finally did was add an alert between those two methods. The alert is annoying to me, but it makes the script work in IE, item is added and customer is taken to shopping cart. In Mozilla, customer is not taken to cart but item is added and an alert is given.

Best I can do for now, but if you have an answer, what she wants is simply for visitor to be sent to cart and item added to cart when "Add to Basket" button is clicked :huh:

Link to post
Share on other sites

I get this with estelle's mod

Warning: Cannot modify header information - headers already sent by (output started at /home/vitaminl/public_html/includes/content/viewProd.inc.php:221) in /home/vitaminl/public_html/includes/boxes/shoppingCart.inc.php on line 83

Link to post
Share on other sites
Guest estelle

Okay, I'm thinking you must have some whitespace after the closing ?> at the end of viewProd.inc.php. Remove that and it should work.

(Sorry about your problems with emailing me - Gmail only recently started rejecting particular zip files, argh)

Estelle.

Link to post
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...