MageBridge directly to checkout
Wednesday, 19 May 2010
Once in a while on the Magento forums, the question comes up if a product could be checkout directly: This would mean that a customer clicks on a link "Checkout this product" and is redirected directly to the checkout, instead of the intermediate shopping cart. This is not possible in Magento without programming. So we decided to offer you this in MageBridge instead - out of the box.
Adding products to the cart
With Magento it's possible to add products to the cart, just by using its numeric ID. For example, if there would be a product with ID 17, this product could be added to the shopping cart by using the following URL:
http://MAGENTO/checkout/cart/add/product/17
After this, Magento will redirect back to the previous page or to the shopping cart page.
Enter MageBridge
Now, this very same link can be replicated to Joomla! using MageBridge:
http://JOOMLA/shop/checkout/cart/add/product/17
But instead of working URLs directly, you can also create a Menu-Item which adds the product automatically to the cart. Forget about numeric IDs, forget about difficult URLs, just click away.
Creating a Menu Item
Within Joomla!, you can navigate to the Menu Manager and choose to add a new Menu-Item. If you select as type MageBridge, you see a lot of different options among which an option Add to cart.
Within the parameters of this new Menu-Item you can easily select the right Magento product through a modal popupbox (see below).

Setting the HTTP Referrer
Now back to the original purpose of this post, what we want to accomplish is not only that a customer is able to add the product to the cart: The customer should be redirected directly to the checkout as well.
The architecture of MageBridge allows for this. When bridging Magento and Joomla!, it tries to act as a browser. A browser would tell Magento which URL was the previous page by setting the so-called HTTP Referrer. So MageBridge should also send the HTTP Referrer to Magento.
Normally, MageBridge takes just the HTTP Referrer from the browser. But in this case, we want to spoof the HTTP Referrer. MageBridge allows you to do so by editing the Redirect Page parameter.
By setting this to checkout/onepage, the customer is redirected to the Magento checkout after the product has been added to cart. That's it!
