<?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; shop</title>
	<atom:link href="http://nemops.com/tag/shop/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>Private Orders Shop in PrestaShop and thirty bees part 2: hide shopping options for visitors</title>
		<link>http://nemops.com/private-orders-in-prestashop-thirty-bees-2-hide-shopping-options-for-visitors/</link>
		<comments>http://nemops.com/private-orders-in-prestashop-thirty-bees-2-hide-shopping-options-for-visitors/#comments</comments>
		<pubDate>Mon, 18 Jun 2018 10:54:39 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[private]]></category>
		<category><![CDATA[shop]]></category>
		<category><![CDATA[thirtybees]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=3138</guid>
		<description><![CDATA[<p>In this second tutorial we will see how to prevent orders from non-registered customers, which is also necessary in case you applied the previous tutorial and are currently using a one page checkout. Watch the screencast Text Version METHOD 1 – Selectively enabling catalog mode If we don’t need to display prices to our visitors, [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/private-orders-in-prestashop-thirty-bees-2-hide-shopping-options-for-visitors/">Private Orders Shop in PrestaShop and thirty bees part 2: hide shopping options for visitors</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>In this second tutorial we will see how to prevent orders from non-registered customers, which is also necessary in case you applied the previous tutorial and are currently using a one page checkout.<br />
<span id="more-3138"></span></p>
<h2>Watch the screencast</h2>

	<div class="video-embed">
		<iframe width="640" height="360" src="http://www.youtube.com/embed/TQQuckN9HdQ" frameborder="0" allowfullscreen></iframe><p><a href="https://www.youtube.com/user/NemoPostScriptum/videos" rel="nofollow" title="Subscribe Post Scriptum's Youtube Channel">Subscribe Post Scriptum's Youtube Channel</a></p>	</div>
<h2>Text Version</h2>
<h3>METHOD 1 – Selectively enabling catalog mode</h3>
<p>If we don’t need to display prices to our visitors, the simplest and quickest way to proceed is by selectively enable catalog mode. Open classes/controller/FrontController.php, and locate the following string, inside the init method:</p>
<pre class="brush: php; title: ; notranslate">
'PS_CATALOG_MODE' =&gt; (bool)Configuration::get('PS_CATALOG_MODE') || (Group::isFeatureActive() &amp;amp;&amp;amp; !(bool)Group::getCurrent()-&gt;show_prices),
</pre>
<p>Replace it with the following:</p>
<pre class="brush: php; title: ; notranslate">
'PS_CATALOG_MODE' =&gt; $catalog_mode || (Group::isFeatureActive() &amp;amp;&amp;amp; !(bool)Group::getCurrent()-&gt;show_prices),
</pre>
<p>We need to create that $catalog_mode variable of course, so let’s add this before the whole assign block:</p>
<pre class="brush: php; title: ; notranslate">
$catalog_mode = (bool)Configuration::get('PS_CATALOG_MODE');
if(!$this-&gt;context-&gt;customer-&gt;id)
    $catalog_mode = true;
</pre>
<p>As you can see, we simply check if the customer id is set (that is, if the user is logged in) and if so, we set catalog mode to true, effectively disabling all cart functionalities. This however left us with a useless cart block, and without prices. Let’s see how to handle it differently then!</p>
<div class="separator"></div>
<h3>METHOD 2 – Selectively disable products</h3>
<p>I will create an override for this one, so in override/classes, let’s create a new file named Product.php.</p>
<p>Let&#8217;s open it up, and copy over the construct method from the core product class. Get rid of everything inside it, and simply add the following:</p>
<pre class="brush: php; title: ; notranslate">
Class Product extends ProductCore
{
    public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
    {
        parent::__construct($id_product, $id_lang, $id_shop);

        if(!Context::getContext()-&gt;customer-&gt;id)
            $this-&gt;available_for_order = false;
    }
}
</pre>
<p>This will take care of the product page. Now for the product list, the property is set elsewhere, and specifically in the getProductProperties method (without s). Copy the whole method from the original class again, but this time leave the content, and just append the following code at the end, right before self::$producPropertiesCache[$cache_key] = $row;</p>
<pre class="brush: php; title: ; notranslate">
if(!$context-&gt;customer-&gt;id)
    $row['available_for_order'] = false;
</pre>
<p>And that’s all we need! Since we created a new override, remember it’s necessary to erase cache/class_index.php in order for the changes to take place.</p>
<p>The post <a rel="nofollow" href="http://nemops.com/private-orders-in-prestashop-thirty-bees-2-hide-shopping-options-for-visitors/">Private Orders Shop in PrestaShop and thirty bees part 2: hide shopping options for visitors</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/private-orders-in-prestashop-thirty-bees-2-hide-shopping-options-for-visitors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add the state to your Shop&#8217;s Address in PrestaShop Invoices</title>
		<link>http://nemops.com/add-the-state-to-your-shops-address-in-prestashop-invoices/</link>
		<comments>http://nemops.com/add-the-state-to-your-shops-address-in-prestashop-invoices/#comments</comments>
		<pubDate>Wed, 31 May 2017 10:37:45 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[invoice]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[prestashop modules]]></category>
		<category><![CDATA[shop]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=3030</guid>
		<description><![CDATA[<p>PrestaShop&#8217;s invoices always lacked the state in the shop&#8217;s address information. Let&#8217;s see how to take it back! Watch the screencast Text Version Assigning the state id to the shop&#8217;saddress Open up OrderInvoice.php, located in classes/order. Locate the method named getCurrentFormattedShopAddress, it&#8217;s the one responsible for creating the shop&#8217;s address in the invoice. You will [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/add-the-state-to-your-shops-address-in-prestashop-invoices/">Add the state to your Shop&#8217;s Address in PrestaShop Invoices</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>PrestaShop&#8217;s invoices always lacked the state in the shop&#8217;s address information. Let&#8217;s see how to take it back!</p>
<p><span id="more-3030"></span></p>
<h2>Watch the screencast</h2>

	<div class="video-embed">
		<iframe width="640" height="360" src="http://www.youtube.com/embed/JLRw0abi3G0" frameborder="0" allowfullscreen></iframe><p><a href="https://www.youtube.com/user/NemoPostScriptum/videos" rel="nofollow" title="Subscribe Post Scriptum's Youtube Channel">Subscribe Post Scriptum's Youtube Channel</a></p>	</div>
<h2>Text Version</h2>
<h3>Assigning the state id to the shop&#8217;saddress</h3>
<p>Open up <strong>OrderInvoice.php</strong>, located in <em>classes/order</em>. Locate the method named <strong>getCurrentFormattedShopAddress</strong>, it&#8217;s the one responsible for creating the shop&#8217;s address in the invoice. You will notice that there is no &#8220;id_state&#8221; assigned to the address object, so what we need to do is append the following line:</p>
<pre class="brush: php; title: ; notranslate">
$address-&gt;id_state = Configuration::get('PS_SHOP_STATE_ID', null, null, $id_shop);
</pre>
<p>Right after the $address->id_country one. The end result will look like this:</p>
<pre class="brush: php; title: ; notranslate">
    public static function getCurrentFormattedShopAddress($id_shop = null)
    {
        $address = new Address();
        $address-&gt;company = Configuration::get('PS_SHOP_NAME', null, null, $id_shop);
        $address-&gt;address1 = Configuration::get('PS_SHOP_ADDR1', null, null, $id_shop);
        $address-&gt;address2 = Configuration::get('PS_SHOP_ADDR2', null, null, $id_shop);
        $address-&gt;postcode = Configuration::get('PS_SHOP_CODE', null, null, $id_shop);
        $address-&gt;city = Configuration::get('PS_SHOP_CITY', null, null, $id_shop);
        $address-&gt;phone = Configuration::get('PS_SHOP_PHONE', null, null, $id_shop);
        $address-&gt;id_country = Configuration::get('PS_SHOP_COUNTRY_ID', null, null, $id_shop);
        $address-&gt;id_state = Configuration::get('PS_SHOP_STATE_ID', null, null, $id_shop);


        return AddressFormat::generateAddress($address, array(), '&lt;br /&gt;', ' ');
    }
</pre>
<p>This is everything it needs, but all of the old addresses will stay broken unless we do something for it!</p>
<h3>Fixing old addresses without state</h3>
<p>Open the file named <strong>HTMLTemplateInvoice.php</strong>, located in <em>classes/pdf</em>. The __construct method is what we are interested in, so right before the &#8220;// header informations&#8221; comment, add the following</p>
<pre class="brush: php; title: ; notranslate">
OrderInvoice::fixAllShopAddresses();
</pre>
<p>This would in theory fix all of the broken addresses. However, since the method only fills those entries without an address associated, we need to edit the function itself. As you can see, it&#8217;s part of the OrderInvoice class, so let&#8217;s hop back to it, and find it at the very end:</p>
<pre class="brush: php; title: ; notranslate">
    public static function fixAllShopAddresses()
    {
        $shopIds = Shop::getShops(false, null, true);
        $db = Db::getInstance();
        foreach ($shopIds as $idShop) {
            $address = static::getCurrentFormattedShopAddress($idShop);
            $escapedAddress = $db-&gt;escape($address, true, true);

            $db-&gt;execute('UPDATE `'._DB_PREFIX_.'order_invoice` INNER JOIN `'._DB_PREFIX_.'orders` USING (`id_order`)
                SET `shop_address` = \''.$escapedAddress.'\' WHERE `shop_address` IS NULL AND `id_shop` = '.$idShop);
        }
    }
</pre>
<p>See that part with the executing query, at the end of the function? We have to modify the query as follows:</p>
<pre class="brush: php; title: ; notranslate">

            $db-&gt;execute('UPDATE `'._DB_PREFIX_.'order_invoice` INNER JOIN `'._DB_PREFIX_.'orders` USING (`id_order`)
                SET `shop_address` = \''.$escapedAddress.'\' WHERE `id_shop` = '.$idShop);

</pre>
<p>Basically, we got rid of all the conditions apart from the shop one, so that all entries are updated. At this point you can try to load any old invoice to see the result. Bear in mind <strong>you have to do it at least twice, as that code we just added runs after the first generation process.</strong>.</p>
<p>Once it&#8217;s done you can revert back these last two changes, to avoid regenerating addresses every time.</p>
<p>The post <a rel="nofollow" href="http://nemops.com/add-the-state-to-your-shops-address-in-prestashop-invoices/">Add the state to your Shop&#8217;s Address in PrestaShop Invoices</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/add-the-state-to-your-shops-address-in-prestashop-invoices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
