Redirect To Woocommerce Variable Product

Home Forums Quform WordPress Redirect To Woocommerce Variable Product

This topic is: resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #32537
    patdundee
    Participant

    Hi Ally
    Long time since we spoke.
    Post form with redirect in functions php for woocommerce

    https://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, 2 months ago by patdundee.
    #32542
    patdundee
    Participant

    Hi 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 cache

    I am really puzzeled now šŸ™‚

    Thanks

    Patrick

    • This reply was modified 3 years, 2 months ago by patdundee. Reason: still occuring
    • This reply was modified 3 years, 2 months ago by patdundee.
    #32545
    patdundee
    Participant

    Has 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, 2 months ago by patdundee.
    #32547
    patdundee
    Participant

    Solved
    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 show

    Phew šŸ™‚

    Patrick

    • This reply was modified 3 years, 2 months ago by patdundee.
    #32552
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Be inspired. Ā© 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy