• Resolved fitwarrior

    (@fitwarrior)


    With AST and TrackShip’s delivery reporting, I use the code below in functions.php to add a line to all woo emails.

    It works great for all email types (Processing, Shipped, etc) EXCEPT “Delivered” (nothing happens).

    ——————–

    add_action( ‘woocommerce_email_order_details’, ‘custom_email_order_details’, 10, 4 );

    function custom_email_order_details( $order, $sent_to_admin, $plain_text, $email ) {
    $order_id = method_exists( $order, ‘get_id’ ) ? $order->get_id() : $order->id;
    $pymt_proc_acct = get_post_meta( $order->get_order_number(), ‘pymt_proc_acct’, true );
    echo ‘<div>Your bank will show a charge from ‘.$pymt_proc_acct.'</div>’;
    }

    ——————–

    The email sent when status is set to “Delivered” appears to not utilize the same action hook.

    Any ideas on a low footprint way (no extra plugins) to embed a custom text into the Delivered email?

    thanks!

Viewing 15 replies - 1 through 15 (of 20 total)
  • Thread Starter fitwarrior

    (@fitwarrior)

    Not hearding back on this on your product site or on this forum, I temp. solved it by adding the following snippet to your core file:
    /plugins/woo-advanced-shipment-tracking/includes/emails/class-shipment-delivered-email.php on line 170

    $paymentMethod = $order->get_payment_method();
    $pymt_proc_acct = get_post_meta( $order->get_order_number(), ‘pymt_proc_acct’, true );
    if( !empty( $pymt_proc_acct ) ) {
    $message .= ‘<p> </p><div style=\’border-radius:5px;border:2px solid #888;padding: 17px 0;font-size:110%;text-align:center;\’><b>IMPORTANT:</b><br><span style=\’color:blue;\’>Your bank will show a charge from <span style=\’text-decoration:underline;font-weight:bold;\’>’ . $pymt_proc_acct . ‘</span></span></div>’;
    }

    I’m not a developer and know this is a bad practice so Please save humanity from this rogue code by improving this answer.

    Thanks!

    Plugin Author Zorem

    (@zorem)

    Hi @fitwarrior,

    We just released latest version of the AST and added two hooks before and after the order details table in the delivered order email template.
    You can use “wcast_email_before_order_table” or “wcast_email_after_order_table” instead of “woocommerce_email_order_details” hook.

    Thanks,

    Thread Starter fitwarrior

    (@fitwarrior)

    Using the hook “wcast_email_before_order_table” instead of “woocommerce_email_order_details” produces the exact opposite result: ONLY the ‘Delivered’ email shows the custom text.

    So calling the function with both hooks is the way I’ll have to do this.

    On a related note adding “echo $email->id;” to both hooked functions outputs the woo email type (eg. “customer_completed_order”) for every type of order except ‘Delivered’.

    Seems clunky that AST ‘Delivered’ emails aren’t coded to work the same way as the rest.

    Plugin Author Zorem

    (@zorem)

    Hi @fitwarrior,

    You can’t use the “wcast_email_before_order_table” hook in default WooCommerce email because we created our own email order details template in order for users to be able to customize the delivered order email in the customizer and remove all order details, you will have to use both the hooks or edit this email in the email customizer we provide

    Thanks

    Thread Starter fitwarrior

    (@fitwarrior)

    There might be something else going on…

    I use your email customizer to modify ALL woo emails (Partially Shipped, Updated Tracking, In Transit, Return to Sender, Available for Pickup, Delivered).

    Hook “woocommerce_email_order_details” works on ALL BUT “Delivered”, while “wcast_email_before_order_table” ONLY works on “Delivered.”

    At this point my workaround works, so this is just for your edification.

    thanks

    Plugin Author Zorem

    (@zorem)

    Hi, the Delivered email is different since we allow to remove all the transactional order details in the customizer and to add custom content. this email is meant to ask for a review, send the customer instructions on how to use the products or any other information you need to send to the customer when you know that his order was delivered. You can edit it in the customizer and not need to use any hooks.
    Thanks.

    Thread Starter fitwarrior

    (@fitwarrior)

    Oh nice! How?

    How would I add a custom field from the order?

    thanks

    Plugin Author Zorem

    (@zorem)

    Hi, you can use the “wcast_email_before_order_table” or “wcast_email_after_order_table” hooks we created but you must mark the Order details in the delivered email customizer for the hook to display:
    https://tinyurl.com/rfwkp6y
    Next week we will release a version with a custom hook that will not be dependent on the Order details display. We will update you here once its released
    Thanks.

    Thread Starter fitwarrior

    (@fitwarrior)

    …Delivered email …is meant to ask for a review, send the customer instructions on how to use the products or any other information you need to send to the customer when you know that his order was delivered.

    As a 20-year e-com marketer, I’d argue the primary benefit of the “Delivered” status email is simply to alert the customer their order was delivered. The way Amazon does. Adding review links, etc. is a nice bonus.

    …Delivered email is different since we allow to remove all the transactional order details in the customizer and to add custom content… You can edit it in the customizer and not need to use any hooks.

    Then I asked “how” and you said “use the following hooks…” so I assume there’s no direct/UI way yet to customize the “Delivered” email with contents of a custom field.

    Thanks!

    • This reply was modified 5 years ago by fitwarrior.
    Thread Starter fitwarrior

    (@fitwarrior)

    As of 3/23 none of the emails is showing the information I added.

    The hooks we discussed above are no longer working. What changed?

    Wow – so much work and time investment to accomplish something that should be innate in the plugin. Please add the ability to add custom_fields easily in the custom emails.

    If there’s a new set of hooks introduced in the last update – Or you have any other idea that can save me some hours later on – please advise.

    Plugin Author Zorem

    (@zorem)

    Hi, we did some changes, you can read and see the hook reference image here:
    https://www.zorem.com/docs/woocommerce-advanced-shipment-tracking/plugin-settings/#delivered-email-hooks
    Thanks.

    Thread Starter fitwarrior

    (@fitwarrior)

    The heading for that section says “# Delivered Email Hooks”. Will that hook work with the other emails?

    Thread Starter fitwarrior

    (@fitwarrior)

    Ok, so, like before, your hook “wcast_email_before_email_content” affects only “delivered” status emails.

    Other woo emails need the hook “woocommerce_email_order_details”

    In case anyone wants to send a custom message in all customer emails (the value of a custom field in my example), you need to use both hooks…

    ——————–
    add to functions.php
    ——————–

    add_action( 'woocommerce_email_order_details', 'custom_email_order_details', 10, 4 );
    add_action( 'wcast_email_before_email_content', 'custom_email_order_details', 10, 4 );
    
    function custom_email_order_details( $order, $sent_to_admin, $plain_text, $email ) {
    	$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
    	$paymentMethod = $order->get_payment_method();
        if ($paymentMethod == 'custom_payment') {
    		$pymt_proc_acct = get_post_meta( $order->get_order_number(), 'pymt_proc_acct', true );
    		if( !empty( $pymt_proc_acct ) ) {
    			echo '<p>Your bank will show a charge from ' . $pymt_proc_acct . '</p>';
    		}
    	}
    }
    • This reply was modified 4 years, 11 months ago by fitwarrior.
    Thread Starter fitwarrior

    (@fitwarrior)

    Unfortunately it’s been a struggle adding this plugin’s functionality to our business processes.

    But we’re getting there…

    Today we noticed a glitch when there’s multiple tracking #’s… only the first tracking # is shown in emails to customer and in customer’s Account > Orders view.

    Testing example below:

    We added 3 tracking #’s for 3-part shipment.

    Woo order admin page:
    https://photos.app.goo.gl/PiGo2JWUYFPzin496
    (3 different tracking #’s added)

    Customer’s email:
    https://photos.app.goo.gl/oSCZM4dkfLKGAhfW9
    (first tracking # repeated 3 times)

    Customer’s account page:
    https://photos.app.goo.gl/iMVWqzjC8Qg1e6ww5
    (first tracking # repeated 3 times)

    Plugin Author Zorem

    (@zorem)

    Hi, We just released latest version of the AST plugin and fixed the duplicate tracking number issue in a simple layout tracking display.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Custom text in ‘Delivered’ email’ is closed to new replies.