<?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>Freshly Baked Websites</title>
	<atom:link href="http://freshlybakedwebsites.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://freshlybakedwebsites.net</link>
	<description>The Scrapbook of Barry Hughes</description>
	<lastBuildDate>Fri, 08 Mar 2013 17:20:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Bulk Pricing Breakdown</title>
		<link>http://freshlybakedwebsites.net/wordpress/shopp/bulk-pricing-breakdown-with-shopp/</link>
		<comments>http://freshlybakedwebsites.net/wordpress/shopp/bulk-pricing-breakdown-with-shopp/#comments</comments>
		<pubDate>Thu, 24 Jan 2013 21:45:58 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Shopp]]></category>
		<category><![CDATA[Customize]]></category>
		<category><![CDATA[E-Commerce]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://freshlybakedwebsites.net/?p=1212</guid>
		<description><![CDATA[While many online stores, such as clothing retailers, tend to sell individual items there are those businesses that deal in part or even exclusively with bulk items instead. They might for instance have a product where the minimum amount that can be ordered is 100 units. Examples might include: Hardware stores selling pre-defined quantities of [...]]]></description>
				<content:encoded><![CDATA[<p>While many online stores, such as clothing retailers, tend to sell individual items there are those businesses that deal in part or even exclusively with bulk items instead. They might for instance have a product where the minimum amount that can be ordered is 100 units. Examples might include:</p>
<ul>
<li>Hardware stores selling pre-defined quantities of screws or nails</li>
<li>Catering supply businesses selling large numbers of disposable knives and forks</li>
<li>Other businesses selling mass produced items to retailers</li>
</ul>
<p>In this tutorial I am going to look at a scenario where the merchant is using <a title="E-Commerce plugin for WordPress" href="https://shopplugin.net/" target="_blank">Shopp</a><a class="footnote-ref" href="http://freshlybakedwebsites.net/wordpress/shopp/bulk-pricing-breakdown-with-shopp/#shopp-version">[1]</a> to power their online store and where they have set up bulk items by leveraging product variants. To simulate this I created a product called <em>Door Knockers</em> which I am hypothetically selling to hardware stores, letting them order palettes loaded up with 100, 250 or 500 door knockers at a time.</p>
<p>That&#8217;s important because we aren&#8217;t letting customers specify arbitrary quantities in this scenario &#8211; we are only allowing them to buy 100, 250, 500 or whatever quantities we define.</p>
<div class="wp-caption aligncenter" style="width: 444px"><img class=" " title="An example of using product variations for bulk item quantities" alt="Screenshot of a demo product, using variants for preset bulk quantities" src="http://178449512b902bad77e8-25a138bab89c68e25ec917fd7ebfa060.r44.cf2.rackcdn.com/quantity-as-a-product-variant-in-shopp.png" width="434" height="288" /><p class="wp-caption-text">An example I set up with a variant called Quantity, allowing door knockers to be ordered in quantities of 100, 250 or 500.</p></div>
<p>This is all very easy to set up. Simply create or edit the product in question then enable and set up a new variant (in my case I have called it <em>Quantity)</em> then name them accordingly. Simplicity is crucial for what we are going to do in this tutorial and here are the rules you will need to follow for every product where you set this up:<span id="more-1212"></span></p>
<ul>
<li>For each product we are setting up like this we will create a variant called <em>Quantity</em></li>
<li>The options themselves (each reflecting a pre-defined quantity) should be named or labelled with a number &#8211; no letters or other special characters allowed</li>
<li>So for a quantity of 100 items, &#8220;x100&#8243; is a bad option name but &#8220;100&#8243; is a good option name</li>
</ul>
<div class="wp-caption aligncenter" style="width: 310px"><img class="  " title="A quantity variant with each option representing the actual quantity" alt="Screenshot of the Shopp product editor's variant tools" src="http://178449512b902bad77e8-25a138bab89c68e25ec917fd7ebfa060.r44.cf2.rackcdn.com/shopp-quantity-variations-example.png" width="300" height="168" /><p class="wp-caption-text">Example of a &#8220;Quantity&#8221; variant where all of the option names are numbers</p></div>
<p>None of this is particularly revolutionary, it&#8217;s just a convenient way of selling bulk items in predefined quantities. As is normal, the greater the number of items purchased the greater the discount. Looking at my scenario for instance we are offering 100 door knockers for $800.00 (that&#8217;s $8 per knocker) and 500 door knockers for $2,000.00 (at this point we&#8217;re almost giving the things away at just $4 per knocker). At this point, let&#8217;s stop and look at the product on the main catalog page.</p>
<div class="wp-caption aligncenter" style="width: 488px"><img class=" " title="A mix of products including our Door Knockers" alt="Screenshot showing variable products on the default Shopp catalog view" src="http://178449512b902bad77e8-25a138bab89c68e25ec917fd7ebfa060.r44.cf2.rackcdn.com/shopp-catalog-view-variable-from-pricing.png" width="478" height="329" /><p class="wp-caption-text">By default, variable products in Shopp have their price displayed as &#8220;From $xxx&#8221; on catalog and category views</p></div>
<p>In the context of catalog (and category) views the door knocker, as with other variable-price products, is displayed showing the least expensive option first &#8211; in this case, that&#8217;s 100 door knockers for $800.00. Our real objective here is to change this behaviour so that we see the lowest price per item ($4/knocker) instead. For all other products, we are just going to leave them untouched.</p>
<p>Let&#8217;s look at the category.php template and see how the price is generated.</p>
		<div class="code"> 
			<pre class="php" ><code>&lt;p class=&quot;price&quot;&gt; <span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'product'</span><span class="sy0">,</span><span class="st_h">'saleprice'</span><span class="sy0">,</span><span class="st_h">'starting='</span><span class="sy0">.</span>__<span class="br0">&#40;</span><span class="st_h">'from'</span><span class="sy0">,</span><span class="st_h">'Shopp'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span> &lt;/p&gt;</code></pre>
		</div>
<p>Specifically we are interested in the <a title="Review the shopp(product.saleprice) tag docs" href="https://shopplugin.net/api/product-saleprice/" target="_blank">Product Saleprice</a> template tag. A neat thing about these tags is that they can all be filtered &#8211; and our filters can access the same information as the template tag code to make informed decisions. The logic we&#8217;re going to use in our filter is as follows:</p>
<ul>
<li>If there is no variant named <em>Quantity</em> (or just no variants at all) step back and return the default output</li>
<li>Look at the price of every possible variant<a class="footnote-ref" href="http://freshlybakedwebsites.net/wordpress/shopp/bulk-pricing-breakdown-with-shopp/#combinations-and-prices">[2]</a></li>
<li>Determine the price-per-unit (but only record the <em>lowest</em> or <em>cheapest</em> value)</li>
<li>If we were able to determine that, return it &#8211; otherwise return the default output</li>
</ul>
<p>And here is that logic translated into code:</p>
		<div class="code"> 
			<pre class="php" ><code><span class="co4">/**
&nbsp;* Modify the saleprice text for products with a &quot;Quantity&quot; variant; all other
&nbsp;* products should have the saleprice returned without any changes.
&nbsp;*
&nbsp;* For relevant products, Quantity is assumed to contain prices with each label
&nbsp;* evaluating to an integer representing quantity:
&nbsp;*
&nbsp;* [Quantity [ 100 =&gt; 10.00, 250 = 20.00, 500 = 40.00, ... ] ]
&nbsp;*
&nbsp;* This will be used to return text representing the lowest price per unit.
&nbsp;*
&nbsp;* @param $result
&nbsp;* @param array $options
&nbsp;* @param Product $product
&nbsp;* @return string
&nbsp;*/</span>
<span class="kw2">function</span> custom_shopp_saleprice<span class="br0">&#40;</span><span class="re0">$result</span><span class="sy0">,</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a> <span class="re0">$options</span><span class="sy0">,</span> Product <span class="re0">$product</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Load variants and variant prices</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$variants</span> <span class="sy0">=</span> shopp_product_variant_options<span class="br0">&#40;</span><span class="re0">$product</span><span class="sy0">-&gt;</span><span class="me1">id</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$prices</span> <span class="sy0">=</span> shopp_product_variants<span class="br0">&#40;</span><span class="re0">$product</span><span class="sy0">-&gt;</span><span class="me1">id</span><span class="br0">&#41;</span><span class="sy0">;</span>

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// If no variants are set, or there is no &quot;Quantity&quot; variant, return the current result text</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><span class="re0">$variants</span> or <span class="sy0">!</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$variants</span><span class="br0">&#91;</span><span class="st_h">'Quantity'</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="kw1">return</span> <span class="re0">$result</span><span class="sy0">;</span>

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Iterate through the variant prices and establish the lowest price-per-unit</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re0">$prices</span> <span class="kw1">as</span> <span class="re0">$variantPrice</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Promoprice ought to be the current lowest price (even if there is no promo in effect)</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$cost</span> <span class="sy0">=</span> <span class="re0">$variantPrice</span><span class="sy0">-&gt;</span><span class="me1">promoprice</span><span class="sy0">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$quantity</span> <span class="sy0">=</span> absint<span class="br0">&#40;</span><span class="re0">$variantPrice</span><span class="sy0">-&gt;</span><span class="me1">label</span><span class="br0">&#41;</span><span class="sy0">;</span>

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Avoid scenarios where quantity is zero</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$quantity</span> <span class="sy0">!==</span> <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Determine the price per unit - record the lowest value as $perUnit</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$variantPricePerUnit</span> <span class="sy0">=</span> <span class="re0">$cost</span> <span class="sy0">/</span> <span class="re0">$quantity</span><span class="sy0">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$perUnit</span><span class="br0">&#41;</span> or <span class="re0">$variantPricePerUnit</span> <span class="sy0">&lt;</span> <span class="re0">$perUnit</span><span class="br0">&#41;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$perUnit</span> <span class="sy0">=</span> <span class="re0">$variantPricePerUnit</span><span class="sy0">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Unable to determine a price-per-unit? Return the original result</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$perUnit</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="kw1">return</span> <span class="re0">$result</span><span class="sy0">;</span>

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Format and return the price-per-unit</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <a href="http://www.php.net/sprintf"><span class="kw3">sprintf</span></a><span class="br0">&#40;</span><span class="st_h">'%s per item'</span><span class="sy0">,</span> money<span class="br0">&#40;</span><span class="re0">$perUnit</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>


<span class="co4">/**
&nbsp;* Setup our filter. We set the priority to 20 to make it run after Shopp's
&nbsp;* own template tag code and the number of args to 3 because we want to pass
&nbsp;* in the Product object.
&nbsp;*/</span>
add_filter<span class="br0">&#40;</span><span class="st_h">'shopp_tag_product_saleprice'</span><span class="sy0">,</span> <span class="st_h">'custom_shopp_saleprice'</span><span class="sy0">,</span> <span class="nu0">20</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#41;</span><span class="sy0">;</span></code></pre>
		</div>
<p>This can be placed inside your theme&#8217;s functions.php file (or in a plugin if you know what you are doing) and, if you need to remove it in the future, then you can simply delete it or comment it out &#8211; because it only filters the output of the Product Saleprice tag (it doesn&#8217;t change anything in the database) this is quite safe.</p>
<div class="wp-caption aligncenter" style="width: 502px"><img class=" " title="Now we have dynamic per-unit pricing on category/catalog views" alt="Screenshot showing the Shopp catalog page with dynamic prices per unit (item pricing) for relevant items" src="http://178449512b902bad77e8-25a138bab89c68e25ec917fd7ebfa060.r44.cf2.rackcdn.com/shopp-catalog-view-variable-from-pricing-modified.png" width="492" height="342" /><p class="wp-caption-text">The end result. Door knockers and another product with a &#8220;Quantity&#8221; variant have the prices-per-unit displayed appropriately, other products are unaffected.</p></div>
<p>Any questions or problems, please just let me know in the comments.</p>
<h5 id="footnotes">Notes</h5>
<ol>
<li id="shopp-version">In this tutorial I am working with Shopp 1.2.5.</li>
<li id="combinations-and-prices">We look at every variant price because we have to &#8211; if there are three variables (quantity, colour and size) each with 4 different options then there are <a title="Variations mean lots of different price points (potentially) as described here!" href="http://freshlybakedwebsites.net/wordpress/jigoshop/looking-at-jigoshop/#the-variations-problem">64 different possible prices</a> even though there are only 4 quantities. With just a <em>Quantity</em> and a <em>Color</em> variant for example it&#8217;s easy to image an impact on per-unit pricing, such as if black door knockers are cheaper to produce than bronze-effect knockers.</li>
<li>The saleprice template tag options are fully respected only if the default output is returned. The approach used here for instance doesn&#8217;t consider taxation &#8211; but that capability could certainly be added.</li>
<li>This post was requested and generously sponsored by Josh at <a title="Ident-a-Kid" href="http://identakid.com/" target="_blank">Ident-a-Kid Services of America</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://freshlybakedwebsites.net/wordpress/shopp/bulk-pricing-breakdown-with-shopp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Events and Calendars</title>
		<link>http://freshlybakedwebsites.net/services/events-and-calendars/</link>
		<comments>http://freshlybakedwebsites.net/services/events-and-calendars/#comments</comments>
		<pubDate>Fri, 18 Jan 2013 00:54:45 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Services]]></category>

		<guid isPermaLink="false">http://freshlybakedwebsites.net/?p=1200</guid>
		<description><![CDATA[Promoting and publicizing events &#8211; and selling tickets to events &#8211; is a common requirement and The Events Calendar by Modern Tribe is my plugin of choice for this sort of work.]]></description>
				<content:encoded><![CDATA[<p>Promoting and publicizing events &#8211; and selling tickets to events &#8211; is a common requirement and The Events Calendar by Modern Tribe is my plugin of choice for this sort of work.</p>
]]></content:encoded>
			<wfw:commentRss>http://freshlybakedwebsites.net/services/events-and-calendars/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shopp Developer</title>
		<link>http://freshlybakedwebsites.net/services/e-commerce-with-shopp/</link>
		<comments>http://freshlybakedwebsites.net/services/e-commerce-with-shopp/#comments</comments>
		<pubDate>Fri, 18 Jan 2013 00:47:50 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Services]]></category>

		<guid isPermaLink="false">http://freshlybakedwebsites.net/?p=1195</guid>
		<description><![CDATA[I've been working with Shopp, a leading e-commerce plugin for WordPress. for a number of years now. In fact, I'm a core contributor - so this is a piece of software that I know intimately.

Whether you are starting a new e-commerce operation from scratch or need to take your existing Shopp-powered store to the next level, I can help you.]]></description>
				<content:encoded><![CDATA[<p>Full text here.</p>
]]></content:encoded>
			<wfw:commentRss>http://freshlybakedwebsites.net/services/e-commerce-with-shopp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wrapping Widget Titles</title>
		<link>http://freshlybakedwebsites.net/wordpress/wrapping-widget-titles/</link>
		<comments>http://freshlybakedwebsites.net/wordpress/wrapping-widget-titles/#comments</comments>
		<pubDate>Fri, 04 Jan 2013 19:47:48 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Snippet]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://freshlybakedwebsites.net/?p=1181</guid>
		<description><![CDATA[I was doing a little customization to a site today and one of the effects I was to put in place meant I really needed to surround the widget title with an extra span or div in order to apply a little CSS magic. This is fairly straightforward and the following snippet can be added [...]]]></description>
				<content:encoded><![CDATA[<p>I was doing a little customization to a site today and one of the effects I was to put in place meant I really needed to surround the widget title with an extra span or div in order to apply a little CSS magic. This is fairly straightforward and the following snippet can be added to the theme functions.php file to make it happen:</p>
		<div class="code"> 
			<pre class="php" ><code><span class="co1">// Alter the widget title markup</span>
add_filter<span class="br0">&#40;</span><span class="st_h">'dynamic_sidebar_params'</span><span class="sy0">,</span> <span class="st_h">'wrap_widget_titles'</span><span class="sy0">,</span> <span class="nu0">20</span><span class="br0">&#41;</span><span class="sy0">;</span>

<span class="co4">/**
&nbsp;* Wrap the widget titles - including any existing before/after title markup
&nbsp;* inside an extra div we can target with div.widget_title_wrapper.
&nbsp;*
&nbsp;* If we needed to do this selectively we could test against $widget['name']
&nbsp;* or $widget['id'].
&nbsp;*/</span>
<span class="kw2">function</span> wrap_widget_titles<span class="br0">&#40;</span><a href="http://www.php.net/array"><span class="kw3">array</span></a> <span class="re0">$params</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// $params will ordinarily be an array of 2 elements, we are interested</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// only in the first element</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$widget</span> <span class="sy0">=&amp;</span> <span class="re0">$params</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="sy0">;</span>

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Wrap the title</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$widget</span><span class="br0">&#91;</span><span class="st_h">'before_title'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'&lt;div class=&quot;widget_title_wrapper&quot;&gt;'</span><span class="sy0">.</span><span class="re0">$widget</span><span class="br0">&#91;</span><span class="st_h">'before_title'</span><span class="br0">&#93;</span><span class="sy0">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$widget</span><span class="br0">&#91;</span><span class="st_h">'after_title'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="re0">$widget</span><span class="br0">&#91;</span><span class="st_h">'after_title'</span><span class="br0">&#93;</span> <span class="sy0">.</span><span class="st_h">'&lt;/div&gt; '</span><span class="sy0">;</span>

&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$params</span><span class="sy0">;</span>
<span class="br0">&#125;</span></code></pre>
		</div>
<p>Et voila, we now have an extra box surrounding the title &#8211; which we can target with something like <em>div.widget_title_wrapper</em> &#8211; letting us apply a few extra effects.</p>
]]></content:encoded>
			<wfw:commentRss>http://freshlybakedwebsites.net/wordpress/wrapping-widget-titles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Single Month List View</title>
		<link>http://freshlybakedwebsites.net/wordpress/events-calendar/single-month-list-view/</link>
		<comments>http://freshlybakedwebsites.net/wordpress/events-calendar/single-month-list-view/#comments</comments>
		<pubDate>Fri, 28 Dec 2012 16:17:15 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Events Calendar]]></category>
		<category><![CDATA[Snippet]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://freshlybakedwebsites.net/?p=1165</guid>
		<description><![CDATA[By default The Events Calendar&#8217;s upcoming events view is designed to list all events from &#8220;today&#8221; until whenever the last event in the calendar is. What seems to be quite a common request though is to simply use the upcoming events page as a nice list view showing a specific month&#8217;s events. I&#8217;ve seen a few [...]]]></description>
				<content:encoded><![CDATA[<p>By default <a title="Modern Tribe's The Events Calendar plugin" href="http://wordpress.org/extend/plugins/the-events-calendar/" target="_blank">The Events Calendar&#8217;s</a> upcoming events view is designed to list all events from &#8220;today&#8221; until whenever the last event in the calendar is.</p>
<p>What seems to be quite a common request though is to simply use the upcoming events page as a nice list view showing a specific month&#8217;s events. I&#8217;ve seen a few approaches to this but I thought I&#8217;d jot down <a title="Use the upcoming events view as a single month list" href="http://pastebin.com/eyeQ9QvR" target="_blank">this quick hack</a> that allows for URLs like <em>mycalendar.com/events/upcoming/2013-12</em> and then lists only events for that month and year.</p>
		<div class="code"> 
			<pre class="php" ><code><span class="kw2">function</span> get_specified_month<span class="br0">&#40;</span><span class="re0">$uri</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Look for patterns like 2099-12 at the end of the URI</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$month_pattern</span> <span class="sy0">=</span> <span class="st_h">'[0-9]{4}-[0-9]{2}'</span><span class="sy0">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$optional_slash</span> <span class="sy0">=</span> <span class="st_h">'/?'</span><span class="sy0">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$pattern</span> <span class="sy0">=</span> <span class="st0">&quot;#(<span class="es4">$month_pattern</span>)(<span class="es4">$optional_slash</span>)$#&quot;</span><span class="sy0">;</span>

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Check for matches</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$match</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/preg_match"><span class="kw3">preg_match</span></a><span class="br0">&#40;</span><span class="re0">$pattern</span><span class="sy0">,</span> <span class="re0">$uri</span><span class="sy0">,</span> <span class="re0">$match</span><span class="br0">&#41;</span> <span class="sy0">!==</span> <span class="nu0">1</span><span class="br0">&#41;</span> <span class="kw1">return</span> <span class="kw4">false</span><span class="sy0">;</span>

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// We are interested only in the year/date portion</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$match</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>

<span class="kw2">function</span> upcoming_single_month_view<span class="br0">&#40;</span>WP_Query <span class="re0">$query</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// We are only interested in requests to view upcoming events</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$query</span><span class="sy0">-&gt;</span><span class="me1">query_vars</span><span class="br0">&#91;</span><span class="st_h">'eventDisplay'</span><span class="br0">&#93;</span> <span class="sy0">!==</span> <span class="st_h">'upcoming'</span><span class="br0">&#41;</span> <span class="kw1">return</span><span class="sy0">;</span>

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Has a specific month been specified?</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$month</span> <span class="sy0">=</span> get_specified_month<span class="br0">&#40;</span><span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st_h">'REQUEST_URI'</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$month</span> <span class="sy0">===</span> <span class="kw4">false</span><span class="br0">&#41;</span> <span class="kw1">return</span><span class="sy0">;</span>

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Set the start date, end date</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$query</span><span class="sy0">-&gt;</span><span class="me1">query_vars</span><span class="br0">&#91;</span><span class="st_h">'start_date'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="re0">$month</span><span class="sy0">.</span><span class="st_h">'-01'</span><span class="sy0">;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$query</span><span class="sy0">-&gt;</span><span class="me1">query_vars</span><span class="br0">&#91;</span><span class="st_h">'end_date'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="re0">$month</span><span class="sy0">.</span><span class="st_h">'-31'</span><span class="sy0">;</span>
<span class="br0">&#125;</span>

<span class="co1">// We'll run our filter later than TribeEventsQuery::setArgsFromDisplayType()</span>
add_filter<span class="br0">&#40;</span><span class="st_h">'parse_tribe_event_query'</span><span class="sy0">,</span> <span class="st_h">'upcoming_single_month_view'</span><span class="sy0">,</span> <span class="nu0">20</span><span class="br0">&#41;</span><span class="sy0">;</span></code></pre>
		</div>
<p>It really is a hack and I&#8217;ve paid no heed whatsoever to scenarios like a given month with a large number of events (and so requiring pagination) &#8211; but I do often find myself needing code like this as a quick starting point <a title="Helping people out as a Modern Tribe happiness engineer" href="http://tri.be/support/forums/topic/mini-calendar-click-month-display-events-from-that-month/" target="_blank">to help people out</a> so will record it here for posterity and my own convenience <img src='http://freshlybakedwebsites.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  <span id="more-1165"></span></p>
<h5 id="footnotes">Notes</h5>
<ol>
<li><span style="line-height: 13px;">The sharp eyed may note my casual assignment of <em>31</em> to form the last day of the month and wonder at my folly - February never has 31 days, after all &#8211; but as the date is used in a basic string comparison we can actually get away with this.<br />
</span></li>
<li>Spoiler alert! Though useful for The Events Calendar 2.x, some pretty major changes are apparently underway for version 3.0 so it may well be far easier to do this quite soon.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://freshlybakedwebsites.net/wordpress/events-calendar/single-month-list-view/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CleverWP Interview</title>
		<link>http://freshlybakedwebsites.net/wordpress/cleverwp-interview/</link>
		<comments>http://freshlybakedwebsites.net/wordpress/cleverwp-interview/#comments</comments>
		<pubDate>Thu, 27 Dec 2012 16:19:51 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://freshlybakedwebsites.net/?p=1158</guid>
		<description><![CDATA[It was fun to be interviewed by Lars Koudal of CleverWP.com recently. Check out the interview!]]></description>
				<content:encoded><![CDATA[<p>It was fun to be interviewed by Lars Koudal of CleverWP.com recently. <a title="Barry Hughes being interviewed about PHP development on cleverwp.com" href="http://cleverwp.com/barry-hughes-interview/" target="_blank">Check out the interview!</a></p>
<div class="wp-caption aligncenter" style="width: 514px"><a href="http://cleverwp.com/barry-hughes-interview/"><img class=" " alt="Screenshot showing a segment on an interview on cleverwp.com" src="http://178449512b902bad77e8-25a138bab89c68e25ec917fd7ebfa060.r44.cf2.rackcdn.com/clever-wp-interview-dec-2012.png" width="504" height="418" /></a><p class="wp-caption-text">Interview on CleverWP.com &#8211; a source of tips, tricks and WordPress related news.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://freshlybakedwebsites.net/wordpress/cleverwp-interview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Say Thanks to Your Customers</title>
		<link>http://freshlybakedwebsites.net/wordpress/shopp/say-thanks-to-your-customers/</link>
		<comments>http://freshlybakedwebsites.net/wordpress/shopp/say-thanks-to-your-customers/#comments</comments>
		<pubDate>Sat, 22 Dec 2012 18:22:25 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Shopp]]></category>
		<category><![CDATA[Snippet]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://freshlybakedwebsites.net/?p=1100</guid>
		<description><![CDATA[First things first: I&#8217;d like to stop and say thank you to all of my customers and everyone I work with &#8211; and wish you all a very happy christmas and new year. By happy coincidence, this post is all about saying thanks: saying thank you to your customers when they buy something is a nice touch [...]]]></description>
				<content:encoded><![CDATA[<p>First things first: I&#8217;d like to stop and say thank you to all of my customers and everyone I work with &#8211; and wish you all a very happy christmas and new year. By happy coincidence, this post is all about saying thanks: saying <em>thank you</em> to your customers when they buy something is a nice touch and I&#8217;m going to look at doing just that using this tasty recipe:</p>
<ul>
<li><a title="WordPress - free, open source publishing" href="http://wordpress.org/" target="_blank">WordPress 3.5</a> and <a title="E-Commerce plugin for WordPress" href="https://shopplugin.net/" target="_blank">Shopp 1.2.5</a> will form the base</li>
<li><img class="alignright no-adornment" alt="Holly and berries" src="http://178449512b902bad77e8-25a138bab89c68e25ec917fd7ebfa060.r44.cf2.rackcdn.com/holly-and-berries-decoration-seasonal-xmas.png" width="141" height="83" /><a title="A raft of customization is achievable using Shopp content templates" href="https://shopplugin.net/api/category/templates/content-templates/" target="_blank">Content templates</a> for the decorative icing</li>
<li><a title="Get your ingredients straight from the source!" href="http://core.trac.wordpress.org/browser/tags/3.5/wp-includes/post.php#L0" target="_blank">Post functions</a> and a <a title="The codex neatly describes what pages are and how they should be used" href="http://codex.wordpress.org/Pages" target="_blank">humble page</a>, because if you are doing this for a client they may want to easily change the thank you message itself &#8211; especially at or following this time of year &#8211; without having to get their hands sticky mixing code and rolling out HTML</li>
</ul>
<p>Once a customer places an order, a confirmation email is dispatched automatically, so half the work is already done here. All we want to do is shoehorn in a little message and what we will do is use a custom template to override the default one used by Shopp.</p>
<p>The process of overriding default templates is covered over in the <a title="Read about templates in the Shopp documentation" href="https://shopplugin.net/docs/the-catalog/theme-templates/" target="_blank">Shopp documentation</a> quite nicely, but for anyone who is unfamiliar with this the basic idea is to create a directory named <em>shopp</em> within your theme directory. For instance, if your theme is <em>Twenty Eleven</em> then the path to any custom Shopp templates would look like this:</p>
<div class="code">
<pre><code>wp-content/themes/twentyeleven/shopp/ ...</code></pre>
</div>
<p>In this case, we are going to override <a title="Order confirmation email template" href="https://shopplugin.net/api/email-order-php-content-template/" target="_blank">email-order.php</a> so at the end of this exercise a new version of that file should live in the above folder, like so (obviously if you are using a different theme then <em>twentyeleven</em> isn&#8217;t going to be part of the path):</p>
<div class="code">
<pre><code>wp-content/themes/twentyeleven/shopp/email-order.php</code></pre>
</div>
<p>If you&#8217;ve already installed custom templates then you may even have this file already in place. If you do, it&#8217;s contents probably look something like this:</p>
		<div class="code"> 
			<pre class="php" ><code>Content-type: text/html; charset=utf-8
From: <span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'email-from'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>
To: <span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'email-to'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>
Subject: <span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'email-subject'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>

&lt;html&gt;

&lt;div id=&quot;header&quot;&gt;
&lt;h1&gt;<span class="kw2">&lt;?php</span> bloginfo<span class="br0">&#40;</span><span class="st_h">'name'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>&lt;/h1&gt;
&lt;h2&gt;<span class="kw2">&lt;?php</span> _e<span class="br0">&#40;</span><span class="st_h">'Order'</span><span class="sy0">,</span><span class="st_h">'Shopp'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span> <span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'id'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>&lt;/h2&gt;
&lt;/div&gt;
&lt;div id=&quot;body&quot;&gt;

<span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'receipt'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>

<span class="kw2">&lt;?php</span> <span class="kw1">if</span> <span class="br0">&#40;</span>shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'notpaid'</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> shopp<span class="br0">&#40;</span><span class="st_h">'checkout'</span><span class="sy0">,</span><span class="st_h">'get-offline-instructions'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">:</span> <span class="sy1">?&gt;</span>
&nbsp; &nbsp; &lt;p&gt;<span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'checkout'</span><span class="sy0">,</span><span class="st_h">'offline-instructions'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>&lt;/p&gt;
<span class="kw2">&lt;?php</span> <span class="kw1">endif</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>

&lt;/div&gt;

&lt;/html&gt;</code></pre>
		</div>
<p>So pretty straightforward. This is an approximation of what it&#8217;s output looks like:</p>
<div style="background: #fff; border: 5px solid #dadada; margin: 15px 25px; padding: 15px 20px;">
<h1 style="font-size: 20px; line-height: 1.2; margin-bottom: 2px;">Freshly Baked Oatcakes</h1>
<h2 style="margin-top: 0px; line-height: 2; font-size: 14px;">Order 15987</h2>
<p>Order Num:15987</p>
<table>
<tbody>
<tr>
<th>Order Date:</th>
<td>December 22, 2012 3:35 pm</td>
</tr>
<tr>
<th>Billed To:</th>
<td>XXXXXXXXXXXX1111 (Visa)</td>
</tr>
<tr>
<th>Transaction:</th>
<td>(<strong>Authorized</strong>)</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td>
<fieldset>
<legend style="display: block; font-weight: bold; color: #999;">Billed to</legend>
<address><big>Tony Bignose</big><br />
123 Hoola Avenue<br />
Nimble Creek, British Columbia<br />
Canada</address>
</fieldset>
</td>
<td>
<fieldset>
<legend style="display: block; font-weight: bold; color: #999;">Ship to</legend>
<address><big>Tony Bignose</big><br />
123 Hoola Avenue<br />
Nimble Creek, British Columbia<br />
Canada</address>
</fieldset>
</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th scope="col">Items Ordered</th>
<th style="font-weight: bold; text-align: left;" scope="col">Quantity</th>
<th style="font-weight: bold; text-align: right;" scope="col">Item Price</th>
<th style="font-weight: bold; text-align: right;" scope="col">Item Total</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: none;">Premium Grade Oatcakes, <em>40kg</em></td>
<td style="border: none;">1</td>
<td style="border: none; text-align: right;">$41.32</td>
<td style="border: none; text-align: right;">$41.32</td>
</tr>
<tr>
<th colspan="3" scope="row">$41.32</th>
</tr>
<tr>
<th style="font-weight: bold; text-align: right; padding: 10px 0 0 0;" colspan="3" scope="row">Shipping</th>
<td style="border: none; text-align: right; padding: 10px 0 0 0;">$0.00</td>
</tr>
<tr>
<th style="font-weight: bold; text-align: right; padding: 10px 0 0 0;" colspan="3" scope="row">Tax</th>
<td style="border: none; text-align: right; padding: 10px 0 0 0;">0%</td>
</tr>
<tr>
<th style="font-weight: bold; text-align: right; padding: 10px 0 0 0;" colspan="3" scope="row">Total</th>
<td style="border: none; text-align: right; padding: 10px 0 0 0;">$41.32</td>
</tr>
</tbody>
</table>
</div>
<p>What I want to do here is insert a little message below the header but above the minutiae of the order itself. This can be accomplished very easily simply by inserting a snippet into the template, like so (noting the new paragraph inside <em>div#body):</em></p>
		<div class="code"> 
			<pre class="php" ><code>Content-type: text/html; charset=utf-8
From: <span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'email-from'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>
To: <span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'email-to'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>
Subject: <span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'email-subject'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>

&lt;html&gt;

&lt;div id=&quot;header&quot;&gt;
&lt;h1&gt;<span class="kw2">&lt;?php</span> bloginfo<span class="br0">&#40;</span><span class="st_h">'name'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>&lt;/h1&gt;
&lt;h2&gt;<span class="kw2">&lt;?php</span> _e<span class="br0">&#40;</span><span class="st_h">'Order'</span><span class="sy0">,</span><span class="st_h">'Shopp'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span> <span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'id'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>&lt;/h2&gt;
&lt;/div&gt;
&lt;div id=&quot;body&quot;&gt;

&lt;p&gt; We would like to thank you for placing an order with 
&lt;em&gt;Freshly Baked Oatcakes&lt;/em&gt;
and wish you all the best for the festive season. &lt;/p&gt;


<span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'receipt'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>

<span class="kw2">&lt;?php</span> <span class="kw1">if</span> <span class="br0">&#40;</span>shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'notpaid'</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> shopp<span class="br0">&#40;</span><span class="st_h">'checkout'</span><span class="sy0">,</span><span class="st_h">'get-offline-instructions'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">:</span> <span class="sy1">?&gt;</span>
&nbsp; &nbsp; &lt;p&gt;<span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'checkout'</span><span class="sy0">,</span><span class="st_h">'offline-instructions'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>&lt;/p&gt;
<span class="kw2">&lt;?php</span> <span class="kw1">endif</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>

&lt;/div&gt;

&lt;/html&gt;</code></pre>
		</div>
<p>It&#8217;s that simple and if you are comfortable with everything described so far then that is probably all you need to know. Sometimes though it might be desirable to make the process of editing the message easier &#8211; such as if you are a designer/developer handing off the site to a client and want to empower them to make changes by themselves, without diving into a mix of HTML and PHP.<span id="more-1100"></span></p>
<p>There&#8217;s quite a simple solution here. First, let&#8217;s create a new page. I&#8217;m going to call my page <i>Email Thank You</i> but you could name it whatever you like. We&#8217;re not going to add it to any of our menus, of course, because that&#8217;s not the role that this page is going to play. Instead, it is an easily editable way of storing our thank you message.</p>
<p>So, go ahead and publish the page and take note of the page ID. You can obtain this quite easily by looking at the URL query in your browser&#8217;s address bar when you are viewing the page in the editor:</p>
<div class="code">
<pre><code>http://www.your-cool-website.ca/wp-admin/post.php?<span style="color: #3067ff;" data-mce-mark="1">post=<span style="font-weight: bold;" data-mce-mark="1">240</span></span>&amp;action=edit</code></pre>
</div>
<p>In my example, above, the page (or to be accurate <em>post)</em> ID is 240 and of course this is likely to be different for you. Jot this down somewhere or commit it to memory and let&#8217;s make a final pass at editing our email template:</p>
		<div class="code"> 
			<pre class="php" ><code>Content-type: text/html; charset=utf-8
From: <span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'email-from'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>
To: <span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'email-to'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>
Subject: <span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'email-subject'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>

&lt;html&gt;

&lt;div id=&quot;header&quot;&gt;
&lt;h1&gt;<span class="kw2">&lt;?php</span> bloginfo<span class="br0">&#40;</span><span class="st_h">'name'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>&lt;/h1&gt;
&lt;h2&gt;<span class="kw2">&lt;?php</span> _e<span class="br0">&#40;</span><span class="st_h">'Order'</span><span class="sy0">,</span><span class="st_h">'Shopp'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span> <span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'id'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>&lt;/h2&gt;
&lt;/div&gt;
&lt;div id=&quot;body&quot;&gt;

<span class="kw2">&lt;?php</span>
<span class="co1">// Load the content of our thank you page </span>
<span class="co1">// (change the ID from 240 to whatever is appropriate)</span>
<span class="re0">$page</span> <span class="sy0">=</span> get_post<span class="br0">&#40;</span><span class="nu0">240</span><span class="br0">&#41;</span><span class="sy0">;</span> 
<span class="re0">$message</span> <span class="sy0">=</span> <span class="re0">$page</span><span class="sy0">-&gt;</span><span class="me1">post_content</span><span class="sy0">;</span>

<span class="co1">// We'll add paragraph tags, but no other filters normally</span>
<span class="co1">// used on post content will be used here</span>
<span class="re0">$message</span> <span class="sy0">=</span> wpautop<span class="br0">&#40;</span><span class="re0">$message</span><span class="br0">&#41;</span><span class="sy0">;</span>

<span class="co1">// And display it!</span>
<span class="kw1">echo</span> <span class="re0">$message</span><span class="sy0">;</span>
<span class="sy1">?&gt;</span>


<span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'receipt'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>

<span class="kw2">&lt;?php</span> <span class="kw1">if</span> <span class="br0">&#40;</span>shopp<span class="br0">&#40;</span><span class="st_h">'purchase'</span><span class="sy0">,</span><span class="st_h">'notpaid'</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> shopp<span class="br0">&#40;</span><span class="st_h">'checkout'</span><span class="sy0">,</span><span class="st_h">'get-offline-instructions'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">:</span> <span class="sy1">?&gt;</span>
&nbsp; &nbsp; &lt;p&gt;<span class="kw2">&lt;?php</span> shopp<span class="br0">&#40;</span><span class="st_h">'checkout'</span><span class="sy0">,</span><span class="st_h">'offline-instructions'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>&lt;/p&gt;
<span class="kw2">&lt;?php</span> <span class="kw1">endif</span><span class="sy0">;</span> <span class="sy1">?&gt;</span>

&lt;/div&gt;

&lt;/html&gt;</code></pre>
		</div>
<p>Now we are drawing in the content from our <em>Email Thank You</em> page &#8211; making it a snap for merchants to easily edit the thank you message. This is fairly simple and means the merchant can ensure a seasonally appropriate message is contained in all their order confirmation emails. It&#8217;s also worth considering its limitations and areas for possible improvement.</p>
<ul>
<li>The usual gamut of filters that are applied to post or page content are not applied here. Example: if a smiley face is inserted it will not be transformed into its corresponding emoticon graphic &#8211; and the same applies to other magical bits of filtering that happen behind the scenes.</li>
<li>Embedding images (emoticons included!) in the thank you page content does not mean your customer will be able to see them. Best practice with images in emails is beyond the scope of this tutorial and actually isn&#8217;t something I have a great interest in, but for any devs with time to spare you could look at parsing out any images that have been inserted into the post content and attaching them properly.</li>
</ul>
<p><img class="alignright no-adornment" alt="Bow decoration" src="http://178449512b902bad77e8-25a138bab89c68e25ec917fd7ebfa060.r44.cf2.rackcdn.com/christmas-bow-decoration.png" width="138" height="127" />Hopefully that provides some ideas and also gives a good feel for the process of customizing Shopp templates generally. Now, with that done all that remains is for me to wish you all a final <em>merry christmas and a happy new year!</em></p>
<p>If you have any questions or comments, please feel free to add them below and I&#8217;ll do my best to help over a cup of eggnog.</p>
]]></content:encoded>
			<wfw:commentRss>http://freshlybakedwebsites.net/wordpress/shopp/say-thanks-to-your-customers/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Considering Cache Exceptions</title>
		<link>http://freshlybakedwebsites.net/wordpress/shopp/considering-cache-exceptions-and-widgets/</link>
		<comments>http://freshlybakedwebsites.net/wordpress/shopp/considering-cache-exceptions-and-widgets/#comments</comments>
		<pubDate>Tue, 18 Dec 2012 18:50:56 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Shopp]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://freshlybakedwebsites.net/?p=1095</guid>
		<description><![CDATA[Across on his Optimize My Shopp blog, Lorenzo talks through the basics of setting up W3 Total Cache to work with Shopp. The most important part of this in my opinion is the setting up of exceptions and is just as applicable to other combinations of e-commerce and caching plugin as it is to Shopp/W3TC. [...]]]></description>
				<content:encoded><![CDATA[<p>Across on his <a title="Lorenzo regularly provides tips and snippets to get the most out of Shopp" href="http://optimizemyshopp.com/blog/setup-shopp-12x-with-w3-total-cache-plugin/" target="_blank">Optimize My Shopp blog</a>, Lorenzo talks through the basics of setting up <a title="W3TC can be downloaded from the WordPress plugin directory" href="http://wordpress.org/extend/plugins/w3-total-cache/" target="_blank">W3 Total Cache</a> to work with <a title="Shopp e-commerce for WordPress" href="https://shopplugin.net/" target="_blank">Shopp</a>. The most important part of this in my opinion is the setting up of exceptions and is just as applicable to other combinations of e-commerce and caching plugin as it is to Shopp/<abbr title="W3 Total Cache">W3TC</abbr>.</p>
<p>Since caching effectively &#8220;freezes&#8221; the content of a page we obviously want to avoid this on a cart or checkout page, where it could either cause a lot of confusion for customers or &#8211; worse still &#8211; the details of a previous customer might be frozen in place until the cache clears.</p>
<p>Lorenzo covers this nicely, but it&#8217;s also worth thinking about widgets, such as shopping cart or login widgets. We definitely don&#8217;t want to see these being &#8220;frozen&#8221; &#8211; certainly we don&#8217;t want everyone to see a single customer&#8217;s shopping cart.</p>
<p>Of course, if these widgets have been added across the site then they might not be covered by the basic exceptions set up in <abbr title="W3 Total Cache">W3TC</abbr> so it&#8217;s worth bearing that in mind and giving further consideration to the positioning and use of that sort of widget, or to other methods of preventing there being cached.</p>
]]></content:encoded>
			<wfw:commentRss>http://freshlybakedwebsites.net/wordpress/shopp/considering-cache-exceptions-and-widgets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First Look at Habari</title>
		<link>http://freshlybakedwebsites.net/habari/first-look-at-habari/</link>
		<comments>http://freshlybakedwebsites.net/habari/first-look-at-habari/#comments</comments>
		<pubDate>Wed, 12 Dec 2012 00:05:03 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Habari]]></category>

		<guid isPermaLink="false">http://freshlybakedwebsites.net/?p=1049</guid>
		<description><![CDATA[Once in a while it&#8217;s nice to get some fresh perspective and look at alternative ways of tackling similar problems. I&#8217;ve been mostly been operating in and around WordPress for quite a while now &#8211; but there are some other bits of software out there that can do similar things which I&#8217;ve always wanted to [...]]]></description>
				<content:encoded><![CDATA[<p>Once in a while it&#8217;s nice to get some fresh perspective and look at alternative ways of tackling similar problems. I&#8217;ve been mostly been operating in and around WordPress for quite a while now &#8211; but there are some other bits of software out there that can do similar things which I&#8217;ve always wanted to take the time to explore.</p>
<p><a title="Habari Project website" href="http://habariproject.org/en/" target="_blank">Habari</a> is one of those and with the <a title="Announcement about 0.9 on the Habari blog" href="http://habariproject.org/en/habari-09-released" target="_blank">release of version 0.9</a> I thought I&#8217;d spend a little time looking at what on the surface looks like it might be a lighter, cleaner blogging platform than is WordPress<a class="footnote-ref" href="http://freshlybakedwebsites.net/habari/first-look-at-habari/#wp-is-a-busy-place">[1]</a>.</p>
<p>Installation is straightforward, just as it is with WordPress, and features a single page installer. What I liked about this was that it also gave a choice of theme and basic plugins to enable right off the bat.</p>
<div class="wp-caption aligncenter" style="width: 580px"><img title="Choice of plugins and themes right in the one-page install" src="http://178449512b902bad77e8-25a138bab89c68e25ec917fd7ebfa060.r44.cf2.rackcdn.com/habari-one-page-installer-theme-plugin-choice.png" alt="Screenshot showing plugin and theme options during installation of Habari" width="570" height="681" /><p class="wp-caption-text">When you install Habari you can select a theme and plugins to get you up and running as quickly as possible.</p></div>
<p>I opted for the new (and responsive) Wazi theme, since I had just read about it in the 0.9 announcement, and went with the default selection of plugins. One click later and my new blog was installed and active, all as easy as pie. Next, I decided to login to the dashboard and was pleasantly surprised.</p>
<div class="wp-caption aligncenter" style="width: 500px"><img class=" " title="Clean and minimalist. Absolutely nothing that you don't need." src="http://178449512b902bad77e8-25a138bab89c68e25ec917fd7ebfa060.r44.cf2.rackcdn.com/habari-dashboard.png" alt="Screenshot showing the basic Habari dashboard" width="490" height="229" /><p class="wp-caption-text">I also liked the menu, complete with keyboard shortcuts for rapid access.</p></div>
<p>If you&#8217;ve used WordPress then you&#8217;ll know that the dashboard is a busy, meta-box festooned place. By contrast, Habari&#8217;s dashboard contained nothing unnecessary &#8211; it felt very clean and ordered.<span id="more-1049"></span></p>
<p>The editor was just as spartan, with a title field, the editor textarea itself and an input for tags, plus save and publish buttons. Once again, this couldn&#8217;t be further removed from the WordPress post editor. However, the lack of any formatting tools (with the exception of writing paragraphs, straight out of the box you would have to type in HTML to format your documents) might be a tad uncomfortable for many.</p>
<div class="wp-caption aligncenter" style="width: 489px"><img class=" " title="The Habari editor: love child of a minimalist developer?" src="http://178449512b902bad77e8-25a138bab89c68e25ec917fd7ebfa060.r44.cf2.rackcdn.com/habari-editor-default.png" alt="Screenshot showing the entry editor in Habari" width="479" height="355" /><p class="wp-caption-text">Few assumptions are made; if you need a visual editor you will need to find and install the appropriate plugin.</p></div>
<p>Personally, I liked it and I was confident that I&#8217;d be able to find a plugin to add a few bells and whistles to the editor. This was where things started to jar a little; it may be that the community and infrastructure that has built up around WordPress has rather spoiled me and raised my expectations &#8211; but for instance <a title="Habari Extras can be found on GitHub" href="https://github.com/habari-extras/" target="_blank">Habari Extras</a><a class="footnote-ref" href="http://freshlybakedwebsites.net/habari/first-look-at-habari/#where-are-all-the-plugins">[2]</a> was not quite as easy to search as the <a title="The WordPress plugin directory" href="http://wordpress.org/extend/plugins/" target="_blank">WordPress plugin directory</a>.</p>
<p>Now given that there are far fewer plugins in Habari Extras than there are in its WordPress equivalent you could say I was simply being lazy in not just looking through the list (which is what I did in the end) but, for instance, though I alighted on <a title="jwysiwyg plugin for Habari" href="https://github.com/habari-extras/jwysiwyg" target="_blank">jWYSIWYG</a> as a possible option to abstract away the need to write directly in HTML, searches for terms like <em>visual editor</em> or just <em>editor</em> didn&#8217;t yield anything, probably due to the lack of descriptions.</p>
<p>Installing my first plugin (jWYSIWYG) wasn&#8217;t quite pain free<a class="footnote-ref" href="http://freshlybakedwebsites.net/habari/first-look-at-habari/#expect-nothing">[3]</a>, but then I am new to Habari and there is always going to be a bit of a learning curve with a new system. That said, on this occasion it was enough to make me abandon the use of this plugin.</p>
<p>Some other teething problems occurred when I activated Habari Media Silo &#8211; which you will need if you want to upload images and use them in your posts in a relatively integrated fashion. Unfortunately, although I could upload images to my local silo I couldn&#8217;t insert them into the post (other than by manually typing out the image tag) . As with jWYSIWYG this was due to a Javascript error. It really was a shame as I quite liked the clear, uncluttered media handling aesthetic.</p>
<p>Another feature I thought showed some real potential &#8211; though I admittedly couldn&#8217;t get much out of it after just a few test posts made in quick succession &#8211; was the loupe.</p>
<div class="wp-caption aligncenter" style="width: 528px"><img class=" " title="The Habari timeline or loupe" src="http://wiki.habariproject.org/w/images/9/9a/Timeline_0.7.jpg" alt="Screenshot (from http://wiki.habariproject.org/) showing the timeline/loupe feature of Habari" width="518" height="79" /><p class="wp-caption-text">This screengrab of the timeline or &#8220;loupe&#8221; is from the Habari wiki and demonstrates nicely what it does.</p></div>
<p>The loupe allows you to select a period of time you want to focus in on with just a few clicks and drag operations &#8211; clearly it has the potential to make retrieving a post from a large archive fast and easy. I couldn&#8217;t really put it through it&#8217;s paces after such a casual spot of testing but it is definitely a great concept.</p>
<p>All in all, Habari looks like an interesting package with a lot of potential where the bloat of WordPress is undesirable; that said my feeling is that a novice would not be at home with this unless the initial setup work was taken in hand by a developer &#8211; of course since that is anyway not uncommon when putting together a new site and so may be a moot point.</p>
<p>Yet there are clearly some rough edges, rough enough to be a bit of a deterrent. Even so I could imagine Habari getting under my skin, it&#8217;s got a nice aesthetic and I definitely feel encouraged to explore it further.</p>
<h5 id="footnotes">Notes</h5>
<ol>
<li id="wp-is-a-busy-place">I was working with a client, a busy shop owner who needed a little coaching on how to manage their website, a month ago or two. It was a real eye opener into just how busy and crowded a place the WordPress admin environment can be &#8211; easily forgotten when you spend every day working on WordPress projects. The mental note I made that day to look for a simpler solution was, in a roundabout way, one of the reasons I decided to look at Habari.</li>
<li id="where-are-all-the-plugins">Where should you look when sourcing a plugin? I found references to <a title="Available plugins listed on the Wiki" href="http://wiki.habariproject.org/en/Available_Plugins" target="_blank">three</a> <a title="Habari plugin distribution directory" href="http://habariproject.org/dist/plugins/" target="_blank">different</a> <a title="Habari Extras on GitHub" href="https://github.com/habari-extras/" target="_blank">locations</a> and felt that was a tad confusing for a Habari noob like me. Perhaps they are all interlinked or some are official and others not &#8230; but it did feel just a touch disorganized.</li>
<li id="expect-nothing">Ultimately I abandoned my attempt at using jWYSIWYG. I initially installed and activated jWYSIWYG, discovered the need to enable it on a per-user basis &#8211; which I thought was actually quite a neat feature &#8211; but after again trying to edit something I was tripped up by the fact that it&#8217;s scripts, which depend on jQuery, are enqueued before jQuery itself &#8211; so nothing happens except a JS error. In fairness, this could be a result of recent changes in the 0.9 release.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://freshlybakedwebsites.net/habari/first-look-at-habari/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Glue for Virtual Pages</title>
		<link>http://freshlybakedwebsites.net/wordpress/shopp/glue-for-virtual-pages/</link>
		<comments>http://freshlybakedwebsites.net/wordpress/shopp/glue-for-virtual-pages/#comments</comments>
		<pubDate>Mon, 10 Dec 2012 21:58:57 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Shopp]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://freshlybakedwebsites.net/?p=1042</guid>
		<description><![CDATA[I&#8217;ve added virtual page support to Shopp SEO Glue &#8211; a plugin that helps WordPress SEO by Yoast to work with the Shopp ecommerce plugin. Although generally speaking I don&#8217;t really envision search engines pouring over the customer account page or the order confirm page, I&#8217;ve added a screen to allow control over this because: I [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve added virtual page support to <a title="Shopp SEO Glue on WordPress" href="http://wordpress.org/extend/plugins/shopp-seo-glue/" target="_blank">Shopp SEO Glue</a> &#8211; a plugin that helps WordPress SEO by Yoast to work with the Shopp ecommerce plugin. Although generally speaking I don&#8217;t really envision search engines pouring over the customer account page or the order confirm page, I&#8217;ve added a screen to allow control over this because:</p>
<ul>
<li>I felt like it made things a little more complete</li>
<li>Some people might be doing interesting things with their store that puts these pages in the spotlight in a way that might not be true of more run-of-the-mill installations</li>
</ul>
<div class="wp-caption aligncenter" style="width: 519px"><img class=" " title="Titles and descriptions can be added for Shopp's virtual pages" src="http://178449512b902bad77e8-25a138bab89c68e25ec917fd7ebfa060.r44.cf2.rackcdn.com/seo-shopp-admin-page.png" alt="Screenshot of the Shopp SEO Glue admin page, found in Shopp &gt; Setup &gt; SEO" width="509" height="332" /><p class="wp-caption-text">Easily assign titles and descriptions to virtual pages like the cart or checkout.</p></div>
<p>Version 1.5 of the plugin can be downloaded from it&#8217;s <a title="Shopp SEO Glue 1.5" href="http://wordpress.org/extend/plugins/shopp-seo-glue/" target="_blank">home in the WordPress plugin directory</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://freshlybakedwebsites.net/wordpress/shopp/glue-for-virtual-pages/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
