[solved] 'add to cart' as a link

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
pedes
Power Poster
Power Poster
Posts: 840
Joined: Tue Jan 27, 2009 11:47 am

[solved] 'add to cart' as a link

Post by pedes »

I would like to have the 'add to cart' show as a link !

like:
+ Add to cart
when click on this ... 1 piece is added to the cart

I already looked into the code, probaly i need to put the original 'add to cart' code in my template, let it hide and with the link simulate the submit button ...

But how can i do it ?

anyone kwows how or has an idea ?

Kind regards
Peter
Last edited by pedes on Mon Sep 20, 2010 2:13 pm, edited 1 time in total.
pedes
Power Poster
Power Poster
Posts: 840
Joined: Tue Jan 27, 2009 11:47 am

Re: 'add to cart' as a link

Post by pedes »

anyone ever tried this ?

any suggestion would be welcome.

Thank you very much.

Kind regards,
Peter
Duketown

Re: 'add to cart' as a link

Post by Duketown »

pedes,

Please let us know which ecommerce suite you are addressing this question to.

Duketown

PS. In module Cart Made Simple you would change the template that shows the products.
pedes
Power Poster
Power Poster
Posts: 840
Joined: Tue Jan 27, 2009 11:47 am

Re: 'add to cart' as a link

Post by pedes »

Your right forgot to say that i'm using the cgecommerce suite
so i would like to make a 'add to cart' link for the cartmodule
in the cgecommerce suite

thx for any suggestion

kind regards
peter
lapak
Forum Members
Forum Members
Posts: 33
Joined: Mon Sep 06, 2010 8:43 pm

Re: 'add to cart' as a link

Post by lapak »

Hi, I'm struggling with cart module as well :) This is little hack, I just figured out, but I'm not sure if it work. Just try it:

In Cart admin make addtocart template called "add_to_cart_init" and leave it totally blank.

In your page put:
{Cart action='default' addtocarttemplate='add_to_cart_init'}
//page=... replace with page alias, where you want to be redirected after sending the form

//here, again put id of page, where you will be redirected after
//and again :)
// id of product, you wan to add, you can use smarty vars of course, like $entry->id if you are in Products detail etc.


Submit //here is your submit link

And of course, strip my comments :)
I'm not sure about this, but probably, when you set in Cart admin, default page to redirect after submitting, I think, that all these page parameters, which i use in this template are ignored...

Hope It will work, I will try it when I will have little time...
pedes
Power Poster
Power Poster
Posts: 840
Joined: Tue Jan 27, 2009 11:47 am

Re: 'add to cart' as a link

Post by pedes »

hi lapak,
thank you for your reply ... your solution did not work ... but you came a long way
i would like to thank you because with your starting point i managed a solution  :)

here is what i did to have a link that will add 1 item of a product in the cart
(in the attached pic you see a the summary of products, 'kopen' is dutch for buying ... so thats the add-to-cart link)

first i made some css to style the add-to-cart link, because this is still a button but it looks like a link, in my form i gave the input type submit a class="addtobaglink".

then i made an UDT for retrieve my url and i called it {my_url}
return 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']';
in the summarytemplate i added this form and put everything on 'hidden' except the submit button



id}" />



As you see in the form the {$actionid}returnid" value is empty ("") this is the redirect after the add-to-cart-link is pushed.
I let it empty because i use the cart-preference "opening-page after add-to-cart" in the cart admin tab. but you can also put there the id of the page you want to be redirect after the add-to-cart-link is pushed.
But either it is empty and you use the cart admin preference or you put there the page-id to redirect to and set the admin cart preference to none.

Hope this will help some people

Kind regards
Peter
Attachments
add-to-cart-link-view.jpg
pedes
Power Poster
Power Poster
Posts: 840
Joined: Tue Jan 27, 2009 11:47 am

Re: [solved] 'add to cart' as a link

Post by pedes »

lapak wrote: Great solution :) Just btw: you don't have to make UDT for url retrieval. There is also tag included in core of cmsms {rooturl} which do the same thing :)
thnks lapak,

if i put {rooturl} in as value for {$actionid}returnid" then i get an smarty error  ???

i would like to stay in the same page where i clicked the link ... but i got now solution for this yet !

Peter
lapak
Forum Members
Forum Members
Posts: 33
Joined: Mon Sep 06, 2010 8:43 pm

Re: [solved] 'add to cart' as a link

Post by lapak »

pedes wrote: thnks lapak,

if i put {rooturl} in as value for {$actionid}returnid" then i get an smarty error  ???

i would like to stay in the same page where i clicked the link ... but i got now solution for this yet !

Peter
I didn't mean for returnid, {root_url} returns full url to root of your page ex. http://www.lumiart.cz, so I ment instead of your {my_url}, but then i realized, that you need url also with ?page= parameter, so I deleted my post, but you were quicker :)

I know, that your solution works perfectly well, I'm just writing this, becaouse It's good to learn new and easier ways how to do things in cmsms, for next time :)
At first, I misswrite {rooturl} instead of {root_url}, thats why you get smarty error :)
And, than your UDT may be probably replaced with: {root_url}/?page={$page_alias}
And if you want returid set to actual page, you can have it in variable: {$content_id} but it's not necessary, just like you explained before...
pedes
Power Poster
Power Poster
Posts: 840
Joined: Tue Jan 27, 2009 11:47 am

Re: [solved] 'add to cart' as a link

Post by pedes »

lapak wrote: I didn't mean for returnid, {root_url} returns full url to root of your page ex. http://www.lumiart.cz, so I ment instead of your {my_url}, but then i realized, that you need url also with ?page= parameter, so I deleted my post, but you were quicker :)

I know, that your solution works perfectly well, I'm just writing this, becaouse It's good to learn new and easier ways how to do things in cmsms, for next time :)
At first, I misswrite {rooturl} instead of {root_url}, thats why you get smarty error :)
And, than your UDT may be probably replaced with: {root_url}/?page={$page_alias}
And if you want returid set to actual page, you can have it in variable: {$content_id} but it's not necessary, just like you explained before...
thks lapak for your reply,

i tried your suggestions for {root_url}, {$content_id}
it is working fine

thank you very much

Peter
lapak
Forum Members
Forum Members
Posts: 33
Joined: Mon Sep 06, 2010 8:43 pm

Re: [solved] 'add to cart' as a link

Post by lapak »

Now i just hit on quite simmilar thing, please, can you post your css style, where you achieved look like text?

Thanks a lot.
pedes
Power Poster
Power Poster
Posts: 840
Joined: Tue Jan 27, 2009 11:47 am

Re: [solved] 'add to cart' as a link

Post by pedes »

hi lapak,

this is the css for the link styling, ofcourse you need to change your_div to yours
#your_div input.addtobaglink {width: 48px;  background-color: transparent; color: #fb8547;  font-family: verdana, arial, sans-serif; margin-top: 0px; font-size: 10px; border: 0px solid #efeeee; float: left; cursor:pointer; padding: 3px 0 0 0;}
#your_div input.addtobaglink:hover {width: 48px;  background-color: transparent; color: #fb8547; margin-top: 0px; font-size: 10px; border-bottom: 1px solid #fb8547; float: left; }
hope it will help you.

Kind regards
Peter
lapak
Forum Members
Forum Members
Posts: 33
Joined: Mon Sep 06, 2010 8:43 pm

Re: [solved] 'add to cart' as a link

Post by lapak »

pedes wrote: hi lapak,

this is the css for the link styling, ofcourse you need to change your_div to yours
#your_div input.addtobaglink {width: 48px;  background-color: transparent; color: #fb8547;  font-family: verdana, arial, sans-serif; margin-top: 0px; font-size: 10px; border: 0px solid #efeeee; float: left; cursor:pointer; padding: 3px 0 0 0;}
#your_div input.addtobaglink:hover {width: 48px;  background-color: transparent; color: #fb8547; margin-top: 0px; font-size: 10px; border-bottom: 1px solid #fb8547; float: left; }
hope it will help you.

Kind regards
Peter
Working, thanks!
Post Reply

Return to “Modules/Add-Ons”