• Hallo!
    Is it possible to set up an email notification to our email address whenever someone subscribes to a price drop alert?

Viewing 1 replies (of 1 total)
  • Plugin Author Marin Matosevic

    (@marinmatosevic)

    Hi,

    This isn’t possible in the current plugin version, but it can be achieved with a bit of custom code.

    You can use the snippet below to send an email to the site admin whenever someone subscribes to a price drop alert:

    /**
    * Send admin notification after a new price alert subscription.
    */
    add_action('price_alerts_after_insert', function ($insert_id, $data) {

    $admin_email = get_option('admin_email');
    $product = wc_get_product($data['product_id'] ?? 0);
    $product_name = $product ? $product->get_name() : '-';

    $subject = sprintf(
    '[%s] New Price Alert Subscription',
    get_bloginfo('name')
    );

    $message = "A new price alert subscription has been created.\n\n";
    $message .= sprintf("Email: %s\n", $data['email'] ?? '-');
    $message .= sprintf("Product: %s\n", $product_name);
    $message .= sprintf("Target price: %s\n", $data['target_price'] ?? '-');

    wp_mail($admin_email, $subject, $message);
    }, 10, 2);

    Let me know if you need any help implementing it.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.