• Hi,

    When an order is placed in backorder the standard ‘processing order’ is mailed.
    Can this be adjusted with this plug in?
    So with enough stock -> normal mail
    With backorder items -> other mail

    thx

    Michiel

Viewing 1 replies (of 1 total)
  • Plugin Support Taha

    (@tahaamin)

    Hello @procespartners,

    Thank you for your patience.

    You can achieve this using the following code snippet. Here are the steps:

    1. Create a new custom email for “Backorder”.
    2. Set the Trigger to “New Order (Any Status)”.
    3. In the code below, replace $backorder_email_id = 1; with the actual #ID of your newly created Backorder custom email.
    4. You can continue using your existing “Processing Order” email for orders with sufficient stock.

    Code Snippet:

    add_filter(	'alg_wc_custom_emails_do_send_order_email', 'alg_wc_custom_email_backorder', 10, 3);
    function alg_wc_custom_email_backorder( $do_send, $email, $order ) {
    $backorder_email_id = 1;
    if ( $backorder_email_id !== $email->alg_wc_ce_id ) {
    return $do_send;
    }

    foreach ( $order->get_items() as $item ) {

    if ( ! is_callable( array( $item, 'get_product' ) ) ) {
    continue;
    }

    $product = $item->get_product();

    if (
    $product &&
    $product->backorders_require_notification() &&
    $product->is_on_backorder( $item->get_quantity() )
    ) {
    return true; // Send email
    }
    }

    return false; // Don't send email if no backorder products found
    }

    Please let me know if this works for you.

    Best regards,

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.