-
- hasan89

-
Total Posts: 7
Joined: 2012-12-06
|
hello guys!!
suppose i have non magento based website from where i want sell product .i click the product a get its detail page.i want to add there “ ADD TO CART” button and when i click that button i want it to route me to magento cart just like i have clik magento add to cart butoon.is this possible in any way??
thanks
|
| |
-
- Posted: December 7 2012
-
| top
-
|
 |
 |
 |
|
|
|
|
-
- hasan89

-
Total Posts: 7
Joined: 2012-12-06
|
thanks David for the reply.
i did this
<button onclick=”location.href =’{{config path=”localhost:8080/magento/index.php”}}/checkout/cart/add?product=1&qty;=1′”>Buy It Now</button>
the button is there but its not working on the click.
|
| |
-
- Posted: December 11 2012
-
| top
| # 2
-
|
 |
 |
 |
|
|
-
- davidmanne

-
Total Posts: 5
Joined: 2012-02-03
Frankfurt am Main, Germany
|
Try using the following code:
<button onclick=”location.href =’{{config path=”localhost:8080/magento/index.php”}}/checkout/cart/add/product_id/1/qty/1′”>Buy It Now</button>
The previous url you posted may only work with older versions of Magento.
Let me know if this helps.
|
| |
-
- Posted: December 11 2012
-
| top
| # 3
-
|
 |
 |
 |
|
|
-
- hasan89

-
Total Posts: 7
Joined: 2012-12-06
|
David..i have tried this earlier but it too didn’t work.
let me tell you complete scenerio.i am having a html file where i have list of all the products with their price and other data.and these all products are being fetched from magento database but the html is non magento and it is not in magento folder.
what i want is when i click the product from the list and it goes to product detail page where there is a add to cart button which should take me directly to the magento cart with product added in it..
Hope you get it.
THANKS
|
| |
-
- Posted: December 11 2012
-
| top
| # 4
-
|
 |
 |
 |
|
|
-
- gskacha

-
Total Posts: 20
Joined: 2011-01-06
|
Hi
Here is button code
<button onclick="location.href =’http://MAGENTO_HOST_URL/checkout/cart/add?product=PRODUCT_ID&qty;=1’">Buy It Now</button>
you need to hard code magento host url and pass product id in button url.
|
| |
-
- Posted: December 12 2012
-
| top
| # 5
-
|
 |
 |
 |
|
|
-
- gskacha

-
Total Posts: 20
Joined: 2011-01-06
|
Hi
Here is button code
<button onclick="location.href =’http://MAGENTO_HOST_URL/checkout/cart/add?product=PRODUCT_ID&qty;=1’">Buy It Now</button>
you need to hard code magento host url and pass product id in button url.
|
| |
-
- Posted: December 12 2012
-
| top
| # 6
-
|
 |
 |
 |
|
|
-
- davidmanne

-
Total Posts: 5
Joined: 2012-02-03
Frankfurt am Main, Germany
|
Ah ok,
If the html is not inside the Magento structure then you will need to hard code the url or you could read it from the magento db core_config_data table since you are already reading the products from the database. If you use /checkout/cart/add?product=PRODUCT_ID&qty;=1 or /checkout/cart/add/product_id/123456/qty/1 only matters on what version of Magento you have.
|
| |
-
- Posted: December 12 2012
-
| top
| # 7
-
|
 |
 |
 |
|
|
|
|
-
- hasan89

-
Total Posts: 7
Joined: 2012-12-06
|
Hey David your post was very helpful
one more thing i want to ask is there a way that when i click that button it do its job i.e it add product to the cart but remain on the same page,only give a alert kind of thing that the product is added to the cart. I came to know that there is the option of setting cart button behaviour we can do from magento admin panel but i what about for custom button??
Thanks
|
| |
-
- Posted: December 13 2012
-
| top
| # 9
-
|
 |
 |
 |
|
|
-
- davidmanne

-
Total Posts: 5
Joined: 2012-02-03
Frankfurt am Main, Germany
|
Glad I could help you out,
As far as staying on the same page with a custom button. I would suggest creating a some JavaScript that will call the url via Ajax, check for success/failure and then display the message on you page. I have not done this with Magento myself but it should not be too difficult.
|
| |
-
- Posted: December 14 2012
-
| top
| # 10
-
|
 |
 |
 |
|
|
-
- hasan89

-
Total Posts: 7
Joined: 2012-12-06
|
i would b thankful if u could help me with code plz. b/c i am new to javascripting.
Thanks
|
| |
-
- Posted: December 14 2012
-
| top
| # 11
-
|
 |
 |
 |
|
|
-
- Ryan Sun _Kuafu

-
Total Posts: 316
Joined: 2008-11-14
FL
|
you don’t have to do it with javascript, it can be a form or a link, as long as you know the params you need to send to magento cart controller
|
| |
-
- Posted: December 14 2012
-
| top
| # 12
-
|
 |
 |
 |
|
|
-
- hasan89

-
Total Posts: 7
Joined: 2012-12-06
|
Dear RYAN i didn’t get your point.Please make it clear for me
Thanks
|
| |
-
- Posted: December 15 2012
-
| top
| # 13
-
|
 |
 |
 |
|
|
-
- hasan89

-
Total Posts: 7
Joined: 2012-12-06
|
David i am waiting for your reply.Its about my project PLZ.
|
| |
-
- Posted: December 15 2012
-
| top
| # 14
-
|
 |
 |
 |
|
|