Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.2 kB
11
Indexable
Never
add_action('marketking_new_product_requires_approval', function($product){
    $vendor_id = marketking()->get_product_vendor($product);
    $vendor = new WP_User($vendor_id);
    $vendor_email = $vendor->user_email;

    // Prepare the email heading and subject
    $email_heading = 'Your Product is Pending Approval';
    $subject = 'Your Product is Pending Approval';

    // Load WooCommerce email classes
    if (class_exists('WC_Email')) {
        // Create a new WC_Email instance
        $wc_email = new WC_Email();

        // Use WC_Email methods to format the email content with WooCommerce template
        $message = $wc_email->style_inline(
            $wc_email->wrap_message(
                $email_heading,
                'Hello, your Your Product is Pending Approval. Please wait.'
            )
        );

        // Use wp_mail() function to send the email, with WooCommerce template applied
        wp_mail($vendor_email, $subject, $message, $wc_email->get_headers(), $wc_email->get_attachments());
    } else {
        // Fallback in case WooCommerce classes aren't available
        wp_mail($vendor_email, $subject, 'Hello, your Your Product is Pending Approval. Please wait.');
    }
}, 10, 1);
Leave a Comment