2

I just wants to redirect the add to cart form to a different page. After click on add to cart button i do not wants to go cart page. i just want to go thank you page.

for that i am altering the form

 if($form_id == 'commerce_cart_add_to_cart_form_1'){
            $form['submit']['#value'] = t("Submit Event");
            $form['#submit'][]= 'post_event_save';  
    }

by using the above code i am able to redirect to post event save page but it will not stop in that page again redirect cart page after executing this post_event_save function.

what i have tried post_event_save function

drupal_goto();
$form_state['redirect'] = false;
$form_state['rebuild'] = TRUE;

by printing the form_state variable

[#validate] => Array
                (
                    [0] => commerce_cart_add_to_cart_form_validate
                    [1] => tasteusa_commerce_add_to_cart_form_validate
                )

            [#submit] => Array
                (
                    [0] => commerce_cart_add_to_cart_form_submit
                    [1] => post_event_save
                )

            [#after_build] => Array
                (
                    [0] => commerce_cart_add_to_cart_form_after_build
                    [1] => context_form_alter_node_after_build
                    [2] => test_commerce_after_build
                )

1 Answer 1

3

Check if you have any redirect rules enabled under admin/config/workflow/rules, which is force redirecting you to cart page.

As a solution you can have your custom redirection rule and disable the existing redirection rule, an example redirection rule which redirects to node/2 path after adding product to cart.

{ "rules_add_product_to_cart_redirect" : {
    "LABEL" : "Add Product to Cart Redirect",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "add-to-cart-redirect" ],
    "REQUIRES" : [ "rules", "commerce_cart" ],
    "ON" : { "commerce_cart_product_add" : [] },
    "DO" : [ { "redirect" : { "url" : "node\/2" } } ]
  }
}

In case you import the above remember to change the redirect path from node/2 to your thank-you page.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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