I'm using commerce checkout redirect module in my commerce site, but in the same time I enabled email verification to register, so the user is redirected to user profile page after he log in.
I want to automatically redirect him to checkout page, I created a rule 'when the user logged in - if order is a cart - then redirect to checkout'.
It always redirect the user even if the cart is empty.
What condition I should add to my rule to do that?
I tested a new condition suggested by Channel Islander, it's not working also in my site :
My new rule:
{ "rules_redirect_to_checkout_after_login" : {
"LABEL" : "redirect to checkout after login",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "checkout", "morad" ],
"REQUIRES" : [ "commerce_rules_extra", "rules" ],
"ON" : { "user_login" : [] },
"IF" : [
{ "commerce_rules_extra_compare_line_item_count" : {
"order" : [ "site:current-cart-order" ],
"operator" : "\u003E=",
"value" : "1"
}
}
],
"DO" : [ { "redirect" : { "url" : "[site:url]\/checkout" } } ]
} }
Log when user log in
Information de débogage de Rules :
" Reacting on event L'utilisateur s'est connecté.
0 ms Reacting on event L'utilisateur s'est connecté.
12.51 ms Evaluating conditions of rule redirect admins to dashboard after login. [edit]
13.394 ms The condition user_has_role evaluated to FALSE [edit]
13.403 ms AND evaluated to FALSE.
13.433 ms Evaluating conditions of rule redirect to checkout after login. [edit]
" Reacting on event Calcul du prix de vente d'un produit.
0 ms Reacting on event Calcul du prix de vente d'un produit.
0.245 ms Evaluating conditions of rule Calculer les taxes : Sales tax. [edit]
0.254 ms AND evaluated to TRUE.
" Rule Calculer les taxes : Sales tax fires. [edit]
0 ms Rule Calculer les taxes : Sales tax fires.
0.112 ms Evaluating the action commerce_tax_calculate_by_type. [edit]
1.159 ms Rule Calculer les taxes : Sales tax has fired.
1.478 ms Evaluating conditions of rule Calculer les taxes : VAT. [edit]
1.484 ms AND evaluated to TRUE.
" Rule Calculer les taxes : VAT fires. [edit]
0 ms Rule Calculer les taxes : VAT fires.
0.079 ms Evaluating the action commerce_tax_calculate_by_type. [edit]
" Executing rule Calculer TVA Maroc 10%. [edit]
0 ms Executing rule Calculer TVA Maroc 10%.
0.179 ms Evaluating conditions of rule Calculer TVA Maroc 10%. [edit]
0.188 ms AND evaluated to TRUE.
" Rule Calculer TVA Maroc 10% fires. [edit]
0 ms Rule Calculer TVA Maroc 10% fires.
0.094 ms Evaluating the action commerce_tax_rate_apply. [edit]
0.686 ms Added the provided variable applied_tax of type commerce_price [edit]
0.703 ms Rule Calculer TVA Maroc 10% has fired.
0.931 ms Finished executing of rule Calculer TVA Maroc 10%.
2.55 ms Rule Calculer les taxes : VAT has fired.
4.065 ms Evaluating conditions of rule add ka par options price. [edit]
5.286 ms The condition entity_has_field evaluated to TRUE [edit]
5.294 ms AND evaluated to TRUE.
" Rule add ka par options price fires. [edit]
0 ms Rule add ka par options price fires.
2.376 ms Looping over the list items of commerce-line-item:field-options [edit]
4.179 ms Evaluating the action commerce_line_item_unit_price_add. [edit]
6.962 ms Evaluating the action commerce_line_item_unit_price_add. [edit]
8.387 ms Evaluating the action commerce_line_item_unit_price_add. [edit]
8.746 ms Rule add ka par options price has fired.
14.085 ms Evaluating conditions of rule add ku pro options price. [edit]
14.208 ms The condition entity_has_field evaluated to FALSE [edit]
14.215 ms AND evaluated to FALSE.
14.283 ms Evaluating conditions of rule Annuler le prix pour les produits désactivés dans le panier. [edit]
16.268 ms The condition data_is_empty evaluated to FALSE [edit]
16.403 ms The condition entity_has_field evaluated to TRUE [edit]
16.963 ms The condition data_is evaluated to FALSE [edit]
16.97 ms AND evaluated to FALSE.
16.99 ms Finished reacting on event Calcul du prix de vente d'un produit.
51.739 ms The condition commerce_rules_extra_compare_line_item_count evaluated to FALSE [edit]
51.746 ms AND evaluated to FALSE.
51.76 ms Finished reacting on event L'utilisateur s'est connecté.