Enlace externo para añadir al carrito

We want to get an outside link for a Magento-store page, that would add to cart an item that's linked from a PDF link (it's a technical drawing with some parts that can be ordered separately) I see that Magento uses JavaScript onclick="productAddToCartForm.submit(this)", but it can not be triggered to the specific item like this. Is there any way this can be solved?

BR-:g

preguntado el 09 de marzo de 12 a las 13:03

3 Respuestas

This is the basic url to call:

www.example.com/checkout/cart/add?product=[id]&qty=[qty]

If you want more details on how to do it with options etc. take a look here:

http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/catalog/adding_a_product_to_the_cart_via_querystring

respondido 09 mar '12, 13:03

thank you! it works great. Just one more question: how can I return to Acrobat from the clicked link? It would be the best if it appears for a moment that it was inserted in the Cart, and then it gets back to the pdf from where it was triggered. - Parrilla de gas

@Gershon This my simple cms page, add to cart not working could you pls help me solve this issue -> code justpaste.it/40ryd - Joya

You can give add to cart url like:

<?php echo $this->helper('checkout/cart')->getAddUrl($_product);?>

Respondido el 06 de Septiembre de 14 a las 01:09

You can always loop over your product collection and ask the checkout/cart helper for the url:

$collection = Mage::getResourceModel('catalog/product_collection');
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */
//... add filters to collection as appropriate

$cartHelper = Mage::helper('checkout/cart');
/* @var $cartHelper Mage_Checkout_Helper_Cart */

foreach( $collection as $product ){
    /* @var $product Mage_Catalog_Model_Product */
    $atcUrl = $carthelper->getAddUrl($product);
    //... do what you need to with the above value (echo, fwrite, etc);
}

Note that you can also pass in product-type-specific options as a second param.

respondido 09 mar '12, 15:03

Are you aware of how to pass simple product custom options through using the second paramenter of getAddUrl()? - pspahn

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.