Emailbenachrichtigung sobald Produkt ab Lager ist

Antworten

Emailbenachrichtigung sobald Produkt ab Lager ist

Hallo zusammen,

hier gibts ne tolle contrib http://addons.oscommerce.com/info/3152

Leider macht diese für uns CAO Nutzer wenig Sinn, die Menge wird ja via Cao an oscommerce übergeben. weiss jemand, wie man folgenden code abändern könnte, damit es dann in cao_functions.php eingefügt werden kann?

Gruss

Code: Alles auswählen

			$current_stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$_GET['pID'] . "'");
			$current_stock = tep_db_fetch_array($current_stock_query);
			if ($current_stock['products_quantity'] < 1) {
			  if ($_POST['products_quantity'] > 0) {
				$audience = array();
				$products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in ( '" . (int)$products_id . "')");

				while ($products = tep_db_fetch_array($products_query)) {
				  $audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
															   'lastname' => $products['customers_lastname'],
															   'email_address' => $products['customers_email_address']);
				}

				$product_query_raw = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$_GET['pID'] . "'");
				$product = tep_db_fetch_array($product_query_raw);

				$customers_query_raw = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in ( '" . (int)$products_id . "')");
				$customer = tep_db_fetch_array($customers_query_raw);

				reset($audience);
				while (list($key, $value) = each ($audience)) {
				  $mimemessage = new email(array('X-Mailer: osCommerce System Mailer'));
				  // add the message to the object
				  if (EMAIL_USE_HTML == 'true') {
					$mimemessage->add_html(HTML_NOTIFICATION1 . $value['firstname'] . ' ' . $value['lastname'] . HTML_NOTIFICATION2 . STORE_NAME . HTML_NOTIFICATION3 . $products_id . '">' . $product['products_name'] . HTML_NOTIFICATION4 . '">' . STORE_NAME . HTML_NOTIFICATION5 . $product['products_name'] . HTML_NOTIFICATION6 . $product['products_name'] . HTML_NOTIFICATION7 . STORE_NAME . HTML_NOTIFICATION8 . $products_id . '">' . $product['products_name'] . HTML_NOTIFICATION9 . STORE_NAME);
				  } else {
					$mimemessage->add_text(TEXT_NOTIFICATION1 . $value['firstname'] . ' ' . $value['lastname'] . TEXT_NOTIFICATION2 . STORE_NAME . TEXT_NOTIFICATION3 . $product['products_name'] . TEXT_NOTIFICATION4 . $product['products_name'] . TEXT_NOTIFICATION5 . $product['products_name'] . TEXT_NOTIFICATION6 . STORE_NAME . TEXT_NOTIFICATION7 . $product['products_name'] . TEXT_NOTIFICATION8 . STORE_NAME);
				  }
				  $mimemessage->build_message();
				  $mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT . $product['products_name'], $email_order);
				  // the following line deletes the customer notification so that that after the email is sent, the customer will have to visit the product page and select the notification button in order to receive future email stock notifications
				  tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $products_id . "' ");
				}
			  }
			}

Re: Emailbenachrichtigung sobald Produkt ab Lager ist

sinnvoller wäre:
die Mengen mit CAO ganz normal in den Shop laden (synchronisieren)
und dann ein eigenes PHP-Skript erstellen, das aufgerufen wird nach jeder Synchronisation (oder z.B. zeitgesteuert alle 3 Stunden) und dann alle Kunden anschreibt, die sich für xyz interessieren und deren Produkt wieder auf lager ist.