WordPress.org

Forums

[woocommerce]-[New Feature Request] Preview Email not showing template versions (2 posts)

  1. silverskyhoshi
    Member
    Posted 2 years ago #

    function woocommerce_preview_emails() in woocommerce-admin-functions.php

    Does not preview the template version of the email being sent out.

    upon editing the email templates there no way to preview those changes without processing an order.

    just to dumby up something for what we needed. i added (Copied from the email builder) then added a Preview version of the customer Processing order's template to remove the header, (it was being output twice. i was in a hurry and couldn't go looking for that portion as well.)

    $order = new WC_Order( $order_id );//Where $order_id = 0 or null
    // Buffer
    		ob_start();
    
    		// Get mail template
    		woocommerce_get_template('emails/preview-customer-processing-orders.php', array(
    			'order' => $order,
    			'email_heading' => $email_heading
    		));
    
    		// Get contents
    		$message = ob_get_clean();

    Please update this to reflect the Template Edits so that the preview link works as expected.

    also, add more links to represent the types of emails being sent.

  2. silverskyhoshi
    Member
    Posted 2 years ago #

    here's the entire function rewritten.

    function woocommerce_preview_emails() {
    	if ( isset( $_GET['preview_woocommerce_mail'] ) ) {
    		$nonce = $_REQUEST['_wpnonce'];
    		if ( ! wp_verify_nonce( $nonce, 'preview-mail') )
    			die( 'Security check' );
    
    		global $woocommerce, $email_heading;
    
    		$mailer = $woocommerce->mailer();
    
    		$email_heading = __('Order Received', 'woocommerce');
    
    		$message  = wpautop( __("Thank you, we are now processing your order. Your order's details are below.", 'woocommerce') );
    
    		$message .= '<h2>' . __('Order:', 'woocommerce') . ' ' . '#1000</h2>';
    
    		$order = new WC_Order( $order_id );
    // Buffer
    		ob_start();
    
    		// Get mail template
    		woocommerce_get_template('emails/preview-customer-processing-orders.php', array(
    			'order' => $order,
    			'email_heading' => $email_heading
    		));
    
    		// Get contents
    		$message = ob_get_clean();
    		echo $mailer->wrap_message( $email_heading, $message );
    
    		exit;
    
    	}
    }

Topic Closed

This topic has been closed to new replies.

About this Topic