Jump to content

Alertes mail : déclinaisons pas prise en compte ?


Recommended Posts

Hello la communauté, 

 

je suis webdesigner et touche un peu au code, mais ce n'est clairement pas mon métier.

J'ai un soucis avec l'alerte mail en cas de rupture de stock sur un shop de chaussures, et donc problème avec les différentes tailles.

 

En effet, l'utilisateur inscrit pour être au courant lors d'un réassort de pointure 36 du modèle Toto, sera automatiquement notifié lors de n'importe quel réassort de ce modèle (n'importe quelle taille, ex 37). 

 

Est-ce un bug suite à une mauvaise manipulation vous pensez, ou bien le module alertes mail ne gère pas les déclinaisons ? 

 

infos :

 

Serveur de prod page test : https://www.irrealizm.com/eponyme/e-shop-parent/61-produit-solde.html#/18-pointure-35

 

- 35 et 37 sont sold-out (mon serveur n'est pas sécurisé mais aucune panique).

 

Site officiel en production : http://www.my-eponyme.com

 

Merci encore

 

(ps : j'ai cherché google et ce forum à fond, pas trouvé d'infos  :ph34r: )

Edited by OLIVIER793 (see edit history)
Link to comment
Share on other sites

Vous avez un bug ailleurs, mailsalert gère les combinaisons

	
	public function hookActionUpdateQuantity($params)
	{
		$id_product = (int)$params['id_product'];
		$id_product_attribute = (int)$params['id_product_attribute'];

		$quantity = (int)$params['quantity'];
		$context = Context::getContext();
		$id_shop = (int)$context->shop->id;
		$id_lang = (int)$context->language->id;
		$product = new Product($id_product, false, $id_lang, $id_shop, $context);
		$product_has_attributes = $product->hasAttributes();
		$configuration = Configuration::getMultiple(
			array(
				'MA_LAST_QTIES',
				'PS_STOCK_MANAGEMENT',
				'PS_SHOP_EMAIL',
				'PS_SHOP_NAME'
			), null, null, $id_shop
		);
		$ma_last_qties = (int)$configuration['MA_LAST_QTIES'];

		$check_oos = ($product_has_attributes && $id_product_attribute) || (!$product_has_attributes && !$id_product_attribute);

		if ($check_oos &&
			$product->active == 1 &&
			(int)$quantity <= $ma_last_qties &&
			!(!$this->merchant_oos || empty($this->merchant_mails)) &&
			$configuration['PS_STOCK_MANAGEMENT'])
		{
			$iso = Language::getIsoById($id_lang);
			$product_name = Product::getProductName($id_product, $id_product_attribute, $id_lang);
			$template_vars = array(
				'{qty}' => $quantity,
				'{last_qty}' => $ma_last_qties,
				'{product}' => $product_name
			);

			// Do not send mail if multiples product are created / imported.
			if (!defined('PS_MASS_PRODUCT_CREATION') &&
				file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.txt') &&
				file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.html'))
			{
				// Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients
				$merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->merchant_mails);
				foreach ($merchant_mails as $merchant_mail)
				{
					Mail::Send(
						$id_lang,
						'productoutofstock',
						Mail::l('Product out of stock', $id_lang),
						$template_vars,
						$merchant_mail,
						null,
						(string)$configuration['PS_SHOP_EMAIL'],
						(string)$configuration['PS_SHOP_NAME'],
						null,
						null,
						dirname(__FILE__).'/mails/',
						false,
						$id_shop
					);
				}
			}
		}

		if ($this->customer_qty && $quantity > 0)
			MailAlert::sendCustomerAlert((int)$product->id, (int)$params['id_product_attribute']);
	}

	public function hookActionProductAttributeUpdate($params)
	{
		$sql = '
			SELECT `id_product`, `quantity`
			FROM `'._DB_PREFIX_.'stock_available`
			WHERE `id_product_attribute` = '.(int)$params['id_product_attribute'];

		$result = Db::getInstance()->getRow($sql);

		if ($this->customer_qty && $result['quantity'] > 0)
			MailAlert::sendCustomerAlert((int)$result['id_product'], (int)$params['id_product_attribute']);
	}

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...