Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the photo-gallery domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/xbfzaz/public_html/wp-includes/functions.php on line 6121
Woocommerce eltérő értesítések - Weboldal készítés, SEO, ADS - Sallai Gábor

Weboldal készítés, SEO, ADS – Sallai Gábor

Woocommerce eltérő értesítések

Amennyiben különböző kategóriák esetében különböző címekre küldenél értesítést a rendelésről, az alábbi megoldást kell elhelyeznek a functions.php file-ban:
add_filter( 'woocommerce_email_recipient_new_order', 'custom_email_recipient_new_order', 10, 2 );
function custom_email_recipient_new_order( $recipient, $order ) {
    // Not in backend when using $order (avoiding an error)
    if( ! is_a($order, 'WC_Order') ) return $recipient;


    $recipients_categories = array(
        'email1@email.com'   => 'kategoria1',
        'email2@email.com'   => 'kategoria2',
            );

    // Loop through order items
    foreach ( $order->get_items() as $item ) {
        // Loop through defined product categories
        foreach ( $recipients_categories as $email => $category ) {
            if( has_term( $category, 'product_cat', $item->get_product_id() ) && strpos($recipient, $email) === false ) {
                $recipient .= ',' . $email;
            }
        }
    }
    return $recipient;
}