• Is it possible to create a template with a conditional function that would automatically display certain print if it’s regular orders or a wholesaler? I want a single template condition where it displays a specific print for regular customer or a wholesaler.

    What would be the hook for such code on your template samples to achieve this? Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter seifer1975

    (@seifer1975)

    Example: I’ve created a template “site-template-invoice”, inside it would be a code like:

    if(wholesaler){
    [display for wholesaler invoice]
    }else{
    [display for regular invoice]
    }

    How to create such condition on this plugin for the template code? Thank you.

    Plugin Contributor alexmigf

    (@alexmigf)

    Hello @seifer1975

    How regular orders are different from wholesaler orders? By meta data? Are you using a third party plugin for that?

    Let me know.

    Thread Starter seifer1975

    (@seifer1975)

    Good Day @alexmigf

    I’m just using WooCommerce PDF Invoices & Packing Slips for creating invoices.

    They can differ from there Order Status, the regular customer will have a status “Completed” while the wholesaler will have a status of “Wholesale shipped”

    Is there a hook for this code to achieve?

    Thank you.

    Plugin Contributor kluver

    (@kluver)

    Hi @seifer1975,

    In that case you can use $order->get_status() to check the order status in your custom template. You will have to use the order status slug (which in my example I’m assuming is wholesale_shipped).

    $order_status = $order->get_status();
    if ( $order_status == 'completed' ) {
    	echo 'Customer text here.';
    } elseif ( $order_status == 'wholesale_shipped' ) {
    	echo 'Wholesale text here.';
    }
    • This reply was modified 4 years, 4 months ago by kluver.
    • This reply was modified 4 years, 4 months ago by kluver.
    Thread Starter seifer1975

    (@seifer1975)

    Thank you Kluver but for some reason the code doesn’t work. It gives me an error.

    <?php 
    	$order_status = $order->get_status();
    	
    	if ( $order_status == 'wholesale_shipped' ) {
    		<div style="text-align: center;">
    			<p>Please make payment into the back account.</p>
    			<p>Thank you and have a great day</p>
    		</div>
    	} elseif ( $order_status == 'completed' ) {
    		<div style="text-align: center;">
    			<p>Thank you and have a great day</p>
    		</div>
    	}
    ?>

    This code seems not working.

    Thread Starter seifer1975

    (@seifer1975)

    Or is this code correct?

    <?php if ( $this->order->get_status() == 'wholesale_shipped' || $this->order->get_status() == 'processing' )  : ?>
    				<div style="text-align: center;">
    					<p>Please make payment into the back account.</p>
    					<p>Account Name : br />
    					Account Number : <br />
    					Bank : Bank </p>
    					<p>Thank you and have a great day</p>
    				</div>
    <?php endif; ?>
    Plugin Contributor Ewout

    (@pomegranate)

    The code you posted where you wrote “This code seems not working.” is missing php closing tags before the HTML and opening tags after the HTML. Your other code looks fine but the proof is in the pudding ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Creating Conditional template based on Order Type’ is closed to new replies.