Jump to content

Edit History

knacky

knacky

So add your own parameters and condition there Mail.php.

You can find a more accurate example in ./classes/PaymentModule.php

Eg.:

$id_order = Tools::getValue('id_order') ?: $this->context->order->id;

if ($template == 'delivered' && $id_order){
	$template = 'delivered';
	$order = new Order((int) $id_order);
 	$getProducts = $order->getProducts(true);
	$idLang = (int) $order->id_lang;
	$product_var_tpl_list = [];
	$products_list = '';

	foreach ($getProducts as $product){
		$product_var_tpl = [
			'id_product' => $product['id_product'],
			'id_product_attribute' => $product['id_product_attribute'],
			'reference' => $product['reference'],
			'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
			'quantity' => $product['quantity'],
			'customization' => [],
		];

		if (isset($product['price']) && $product['price']) {
			$product_var_tpl['unit_price'] = Tools::getContextLocale($this->context)->formatPrice($product_price, $this->context->currency->iso_code);
			$product_var_tpl['unit_price_full'] = Tools::getContextLocale($this->context)->formatPrice($product_price,$this->context->currency->iso_code).''. $product['unity'];
		} else {
			$product_var_tpl['unit_price'] = $product_var_tpl['unit_price_full'] = '';
		}

		$product_var_tpl_list[] = $product_var_tpl;

		.....
	}

	$product_var_tpl_list[] = $product_var_tpl;

	$product_list_txt = '';
	$product_list_html = '';
	if (count($product_var_tpl_list) > 0) {
		$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
		$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
	}

	$templateVars= [
		'{products}' => $products,
		'{order_reference}' => $order->reference,
		.....
	];

	$to = $this->context->customer->email;
	$toName = $this->context->customer->firstname . ' ' . $this->context->customer->lastname;

	.....

	$subject = $this->context->getTranslator()->trans(
                                    'Order delivered',
                                    [],
                                    'Emails.Subject',
                                    $orderLanguage->locale
                                );


}

 

knacky

knacky

So add your own parameters and condition there Mail.php.

You can find a more accurate example in ./classes/PaymentModule.php

Eg.:

$id_order = Tools::getValue('id_order') ?: $this->context->order->id;

if ($template == 'delivered' && $id_order){
	$template = 'delivered';
	$order = new Order((int) $id_order);
 	$getProducts = $order->getProducts(true);
	$idLang = (int) $order->id_lang;
	$products = array();

	foreach ($getProducts as $product){
		$products[] = array(
			'reference' => $product['reference'], 
			'name' => $product->name, 
			'customization' => $product['customization'], 
			.....
		);	
	}

	$templateVars= [
		'{products}' => $products,
		'{order_reference}' => $order->reference,
		.....
	];

	$to = $this->context->customer->email;
	$toName = $this->context->customer->firstname . ' ' . $this->context->customer->lastname;

	.....

	$subject = $this->context->getTranslator()->trans(
                                    'Order delivered',
                                    [],
                                    'Emails.Subject',
                                    $orderLanguage->locale
                                );


}

 

knacky

knacky

So add your own parameters and condition there Mail.php.

Eg.:

$id_order = Tools::getValue('id_order') ?: $this->context->order->id;

if ($template == 'delivered' && $id_order){
	$template = 'delivered';
	$order = new Order((int) $id_order);
 	$getProducts = $order->getProducts(true);
    $idLang = (int) $order->id_lang;
	$products = array();

	foreach ($getProducts as $product){
		$products[] = array(
			'reference' => $product['reference'], 
			'name' => $product->name, 
			'customization' => $product['customization'], 
			.....
		);	
	}

	$templateVars= [
		'{products}' => $products,
		'{order_reference}' => $order->reference,
		.....
	];

	$to = $this->context->customer->email;
    $toName = $this->context->customer->firstname . ' ' . $this->context->customer->lastname;

	.....

    $subject = $this->context->getTranslator()->trans(
                                    'Order delivered',
                                    [],
                                    'Emails.Subject',
                                    $orderLanguage->locale
                                );


}

 

×
×
  • Create New...