I am aware of the default Add to cart url (/checkout/cart/add?product=[id]&qty=1), however I also want a Buy it now url that will add to cart then redirect the user to the checkout page (e.g. /checkout/onepage/).

A co-worker suggested echo $_product->getData('buyitnowurl') but that just generates the product's url.


What you want to do is implement an observer which sets the redirectUrl, so you process this execution path:

public function addAction()
    // ...
    try {
        // ...
        $url = $this->_getSession()->getRedirectUrl(true);
        if ($url) {
        } else {

So your URL is taken from the session and it is redirected to the checkout.

I think the easiest is, when you hook into checkout_cart_product_add_after, so you can be sure, that the item was added. You just have to add a parameter you can check in the URL, so you know it was a "Buy now" url.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.