<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NemoPS &#187; tracking</title>
	<atom:link href="http://nemops.com/tag/tracking/feed/" rel="self" type="application/rss+xml" />
	<link>http://nemops.com</link>
	<description>Prestashop Tutorials, Modules and More!</description>
	<lastBuildDate>Wed, 05 Dec 2018 13:25:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.35</generator>
	<item>
		<title>Set the order status to Shipped when adding a tracking code in Prestashop</title>
		<link>http://nemops.com/prestashop-order-status-shipped-tracking/</link>
		<comments>http://nemops.com/prestashop-order-status-shipped-tracking/#comments</comments>
		<pubDate>Mon, 01 Jun 2015 09:34:34 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[orders]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[shipping]]></category>
		<category><![CDATA[tracking]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2435</guid>
		<description><![CDATA[<p>This little trick will save you the time of having to manually change the order status when you add a tracking number for orders, in the Prestashop Back Office. Before proceeding, be aware that this method is not ideal in case you are offering multi shipping (that is, if the same order is associated to [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-order-status-shipped-tracking/">Set the order status to Shipped when adding a tracking code in Prestashop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>This little trick will save you the time of having to manually change the order status when you add a tracking number for orders, in the Prestashop Back Office.</p>
<p><span id="more-2435"></span></p>
<p>Before proceeding, be aware that this method is not ideal in case you are offering multi shipping (that is, if the same order is associated to multiple carriers and tracking numbers), as it would be set to shipped even if not all of the items have been.</p>
<p>That said, open up <strong>AdminOrdersController.php</strong> located in the <em>controllers/admin</em> folder. Locate the following:</p>
<pre class="brush: php; title: ; notranslate">
if (Tools::isSubmit('submitShippingNumber') &amp;&amp; isset($order))
		{
			..
</pre>
<p>Inside this conditional, we are going to plug in our code, and the ideal spot for it would be right before</p>
<pre class="brush: php; title: ; notranslate">
// Send mail to customer
	$customer = new Customer((int)$order-&gt;id_customer);
	$carrier = new Carrier((int)$order-&gt;id_carrier, $order-&gt;id_lang);
</pre>
<p>As at this point the tracking number has already been set. Therefore, let&#8217;s start by adding some lines of code (my line is around 465, in Prestashop 1.6.0.14:)</p>
<pre class="brush: php; title: ; notranslate">

$shipped_status = Configuration::get('PS_OS_SHIPPING');
if($order-&gt;current_state != $shipped_status &amp;&amp; $order-&gt;current_state != Configuration::get('PS_OS_CANCELED'))
{
	// todo
}

</pre>
<p><strong>Explanation:</strong> First, we are grabbing the shipped status from the database configuration, then we check that the current order has not been shipped already (it would be redundant to add another identical status!). We also make sure it&#8217;s not canceled, to avoid any conflict if we accidentally (or necessarily) update the tracking after canceling an order</p>
<p> Inside our new condition, add</p>
<pre class="brush: php; title: ; notranslate">
	$history = new OrderHistory();
	$history-&gt;id_order = $order-&gt;id;
	$history-&gt;id_employee = (int)$this-&gt;context-&gt;employee-&gt;id;

	$history-&gt;changeIdOrderState((int)$shipped_status, $order);
 </pre>
<p> So that we effectively modify the status. Now that the order is changed, we can do two things: sending an extra email to the customer (For the &#8220;shipped&#8221; status) and updating stock in case we use advanced stock management.</p>
<pre class="brush: php; title: ; notranslate">
	$carrier = new Carrier($order-&gt;id_carrier, $order-&gt;id_lang);
	$templateVars = array();
	if ($order-&gt;shipping_number)
		$templateVars = array('{followup}' =&gt; str_replace('@', $order-&gt;shipping_number, $carrier-&gt;url));

	if ($history-&gt;addWithemail(true, $templateVars))
	{
		if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
			foreach ($order-&gt;getProducts() as $product)
				if (StockAvailable::dependsOnStock($product['product_id']))
					StockAvailable::synchronize($product['product_id'], (int)$product['id_shop']);
	}	
 </pre>
<p> Bear in mind that, if you don&#8217;t want to send out any email, you migh as well just paste in the last part:</p>
<pre class="brush: php; title: ; notranslate">

 	if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
			foreach ($order-&gt;getProducts() as $product)
				if (StockAvailable::dependsOnStock($product['product_id']))
					StockAvailable::synchronize($product['product_id'], (int)$product['id_shop']);
 </pre>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-order-status-shipped-tracking/">Set the order status to Shipped when adding a tracking code in Prestashop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-order-status-shipped-tracking/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
