This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tutorials:zencartmods:back_in_stock_notifications.html [2011/07/21 15:04] daigo |
tutorials:zencartmods:back_in_stock_notifications.html [2016/01/28 18:05] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== back in stock notifications ==== | + | ==== Back in stock notifications ==== |
+ | |||
+ | |||
+ | {{:tutorials:zencartmods:notify.png?|}} | ||
+ | |||
We use the [[http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=1108|Back in stock notifications]] plugin for zencart. | We use the [[http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=1108|Back in stock notifications]] plugin for zencart. | ||
Line 53: | Line 58: | ||
</code> | </code> | ||
+ | |||
+ | ==== Individual produts ==== | ||
+ | |||
+ | By default, the **sendBackInStockNotifications()** functions sends notifications to everyone who has subscribed to any item that is back in stock. | ||
+ | |||
+ | In order to make it so you can send notifications to people who are subscribed only to certain item, | ||
+ | |||
+ | in **admin/includes/functions/back_in_stock_notifications_functions.php** line 32 replace | ||
+ | <code php> | ||
+ | function sendBackInStockNotifications($test_mode = false) | ||
+ | </code> | ||
+ | wiwth | ||
+ | <code php> | ||
+ | function sendBackInStockNotifications($test_mode = false, $products_id = 0) | ||
+ | </code> | ||
+ | |||
+ | and replace | ||
+ | <code php> | ||
+ | $email_addresses_query_raw = " | ||
+ | SELECT | ||
+ | bisns.email_address, bisns.name, c.customers_email_address, c.customers_firstname, | ||
+ | c.customers_lastname | ||
+ | FROM | ||
+ | " . TABLE_BACK_IN_STOCK_NOTIFICATION_SUBSCRIPTIONS . " bisns | ||
+ | LEFT JOIN | ||
+ | " . TABLE_PRODUCTS . " p | ||
+ | ON | ||
+ | p.products_id = bisns.product_id | ||
+ | LEFT JOIN | ||
+ | " . TABLE_CUSTOMERS . " c | ||
+ | ON | ||
+ | c.customers_id = bisns.customer_id | ||
+ | WHERE | ||
+ | p.products_quantity > 0 | ||
+ | GROUP BY | ||
+ | email_address, customers_email_address | ||
+ | ORDER BY | ||
+ | email_address, customers_email_address"; | ||
+ | </code> | ||
+ | with | ||
+ | <code php> | ||
+ | if( $products_id == 0) | ||
+ | { | ||
+ | $email_addresses_query_raw = " | ||
+ | SELECT | ||
+ | bisns.email_address, bisns.name, c.customers_email_address, c.customers_firstname, | ||
+ | c.customers_lastname | ||
+ | FROM | ||
+ | " . TABLE_BACK_IN_STOCK_NOTIFICATION_SUBSCRIPTIONS . " bisns | ||
+ | LEFT JOIN | ||
+ | " . TABLE_PRODUCTS . " p | ||
+ | ON | ||
+ | p.products_id = bisns.product_id | ||
+ | LEFT JOIN | ||
+ | " . TABLE_CUSTOMERS . " c | ||
+ | ON | ||
+ | c.customers_id = bisns.customer_id | ||
+ | WHERE | ||
+ | p.products_quantity > 0 | ||
+ | GROUP BY | ||
+ | email_address, customers_email_address | ||
+ | ORDER BY | ||
+ | email_address, customers_email_address"; | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | $email_addresses_query_raw = " | ||
+ | SELECT | ||
+ | bisns.email_address, bisns.name, c.customers_email_address, c.customers_firstname, | ||
+ | c.customers_lastname | ||
+ | FROM | ||
+ | " . TABLE_BACK_IN_STOCK_NOTIFICATION_SUBSCRIPTIONS . " bisns | ||
+ | LEFT JOIN | ||
+ | " . TABLE_PRODUCTS . " p | ||
+ | ON | ||
+ | p.products_id = bisns.product_id | ||
+ | LEFT JOIN | ||
+ | " . TABLE_CUSTOMERS . " c | ||
+ | ON | ||
+ | c.customers_id = bisns.customer_id | ||
+ | WHERE | ||
+ | p.products_quantity > 0 | ||
+ | AND | ||
+ | p.products_id = " . (int)$products_id . " | ||
+ | GROUP BY | ||
+ | email_address, customers_email_address | ||
+ | ORDER BY | ||
+ | email_address, customers_email_address"; | ||
+ | |||
+ | } | ||
+ | |||
+ | </code> | ||
+ | |||
+ | You can now make an admin page that will send notifications only to people subscribed to a certain product by calling **sendBackInStockNotifications(false, YOUR_PID)**. | ||
+ | |||