• Resolved Chee Studio

    (@chee-studio)


    I have two distinct products in a WooCommerce cart. One is a ticket, the other is a fee that must be paid before the user can upload a file (which is being handled by a Gravity Form I’ve created).

    Currently, if I put the link to the page with the Gravity Form on the Order Received page, if someone purchases just a ticket, they would see this link and it would be confusing.

    Is there a way to either have unique confirmation pages once a purchase is complete based on the product purchased?

    If not, are there conditional tags or some kind of hook or filter that would only show the link to the Gravity Form on the Order Received page if the “fee product” is purchased (possibly based on product ID or category ID)?

Viewing 1 replies (of 1 total)
  • Thread Starter Chee Studio

    (@chee-studio)

    After beating on this incessantly, I finally got what I was looking for, so I thought I’d post it. In my case, I wanted to customize the Order Detail/Confirmation page with a link to a form, but only when a certain product is purchased.

    If you want something similar, put this in the order_details.php template:

    global $woocommerce;
    
        $order = new WC_Order( $order_id );
    
        /* This two lines above should already exist, but I have them here so you can
        see where to put the code */
    
    	foreach($order->get_items() as $item) {
    		$_product = get_product($item['product_id']);
    		if ($item['product_id']==154) {
                // Do what you want here..replace the product ID with your product ID
        		}
        	}

    I also tested this by inserting a wp_redirect within the if statement and it seemed to work great, so I imagine you could customize this code with a bunch of if/elseif statements that redirect to different landing pages depending on the product purchased! Hopefully this helps someone!

Viewing 1 replies (of 1 total)
  • The topic ‘Conditional Confirmation/Order Received Page based on Product or Category?’ is closed to new replies.