Home › Forums › Quform WordPress › Redirect To Woocommerce Variable Product
- This topic has 4 replies, 2 voices, and was last updated 3 years, 9 months ago by Ally.
- AuthorPosts
- February 14, 2021 at 12:29 am #32537patdundeeParticipant
Hi Ally
Long time since we spoke.
Post form with redirect in functions php for woocommercehttps://www,websiteaddress/?add-to-cart=xxxx
This has always worked fine, however I have now started adding variable products. When you add this to the product it fials to add to cart
I have tried using the unique product code for the variable item and also the main product code (Which has stayed the same), but it does not work, The form when posted always gets defaulted to the main ID of the product, but as it is a variable product it does not display the item in the cart.
For a standard non variable product the following works
https://www,websiteaddress/?add-to-cart=1234
How would we redirect in functions php when we have to use the variable id
If i type the redirect address manually in the address bar with the variable ID it works, but it does not work when i post the form.
function my_success_redirect_url8($url, Quform_Confirmation $confirmation, Quform_Form $form) { $sytem='Windows'; $managed=$form->getValue('quform_x_x'); $user=$form->getValue('quform_x_x'); $pchoice=$form->getValueText('quform_x_x'); $pchoice=str_replace(',',' - ',$pchoice); if ($managed == 'Managed') { if ($user == 1 ) { $cartID = xxxx; } elseif($user == 5){ $cartID = xxxx; } else { $cartID = xxxx; } } else { if ($user == 1) { $cartID = xxxx; } elseif($user == 5) { $cartID = xxxx; } else { $cartID = xxxx; } } $url=('https://www.mydomain.co.uk/?add-to-cart='.$cartID.'&pchoice='.$pchoice); echo $url; return $url; } add_action('quform_confirmation_redirect_url_8_1', 'my_success_redirect_url8', 10, 3);
- This topic was modified 3 years, 9 months ago by patdundee.
February 15, 2021 at 3:00 pm #32542patdundeeParticipantHi Ally
As aboce i have now told the form to go direct to the product page (See code)function my_success_redirect_url8($url, Quform_Confirmation $confirmation, Quform_Form $form) { $sytem='Windows'; $managed=$form->getValue('quform_x_x'); $user=$form->getValue('quform_x_x'); $pchoice=$form->getValueText('quform_x_x'); $pchoice=str_replace(',',' - ',$pchoice); if ($managed == 'Managed') { if ($user == 1 ) { $cartID = xxxx; } elseif($user == 5){ $cartID = xxxx; } else { $cartID = xxxx; } } else { if ($user == 1) { $cartID = xxxx; } elseif($user == 5) { $cartID = xxxx; } else { $cartID = xxxx; } } $url=('https://www.mydomain.co.uk/product/palmtest); echo $url; return $url; } add_action('quform_confirmation_redirect_url_8_1', 'my_success_redirect_url8', 10, 3);
Whenever i post the form it still is going to
https://www.mywebaddress/?add-to-cart=6588
but the action tells it to do something different.
I have tried this on different browsers on 5 different machines that have never been to my site and the result is the same
I have cleared all server cache, system cache, %temp% on system and all browser cacheI am really puzzeled now 🙂
Thanks
Patrick
February 15, 2021 at 5:07 pm #32545patdundeeParticipantHas Quform got its own cache anywhere?
I have just duplicated the form edited the above code to reflect the new form number and it still did not work
Patrick- This reply was modified 3 years, 9 months ago by patdundee.
February 16, 2021 at 1:50 am #32547patdundeeParticipantSolved
With a variable product you have to set the redirect in the confirmation settings of the form to the prooduct page name as well as the redirect code in the functions php. Make sure you have all variabl eproduct choise for each variable set in woocommerce. Do not sent variables from the form as they will not showPhew 🙂
Patrick
- This reply was modified 3 years, 9 months ago by patdundee.
February 16, 2021 at 12:02 pm #32552AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.