Updated for 1.2 & 1.3: Adding category depth tag to Shopp

Problem: I needed to display sub categories of a category in category.php but only one level deep. Using:

<?php if(shopp('category','hascategories')): ?>
  <?php while(shopp('category','subcategories')): ?>
    //display stuff
  <?php endwhile; ?>
<?php endif; ?>

…displays all subcast AND their subcats. Continue reading “Updated for 1.2 & 1.3: Adding category depth tag to Shopp”

Custom Ordering Shopp (wordpress plugin) products in just one category

Problem: I’ve developed a site using the Shopp ecommerce WordPress Plugin and product ordering is set to ‘Price – Low to High’ at the Client’s request. Splendid. But now – for one category only – he want’s the Products to be give a custom order. In the Shopp presentation settings, ‘Product Order’ is set site-wide.

Solution: I created a custom template for the category in question, then in that template loaded the specific category with the ‘order’ option set to ‘custom’. Here are some steps.

1) Create the category specific template in the ‘Shopp’ theme templates directory in your WordPress theme. In my case the file was called category-truss.php as ‘truss’ is the slug of the category, and it’s a copy of my main category.php template file.

2) At the top of category-truss.php add the API function shopp(‘storefront.category’) like so:

<?php shopp('storefront','category','slug=truss&load=true&order=custom'); ?>
// load=true is needed to stop the functioning spitting out the category directly.
// slug is whatever your category's slug is. See the docs for more 'order' options.

3) In the Shopp Admin area, edit the category you want to custom order, then use the ‘Arrange Products’ button/link. Then drag the products into the order you want and test.

It might be that there’s an easier or better way to do this, if so please let me know in the comments!

Please let me know if this tiny snippet was useful, just one click!
Nope, not helpful...Yep, more useful than not! - +1 thumb, 1 overall.
Loading...

Accessing selected payment type in Shopp Summary.php (Checkout and Order Confirmation page)

Problem: Someone on the Shopp Helpdesk asked how they could display the payment type that a customer had just selected, on the following Order Confirmation page. They were using multiple ‘Offline Payment’ type options, and presumably they needed the customer to be able to visually confirm what they’d selected. As far as I can see, there’s no template tag provided for this.

Solution: All sorts can be pulled from the ShoppShopping() object directly. In this case the following worked:

1
<?php echo ShoppShopping()--->data->Order->Billing->cardtype; ?>

Bonus: To display the same info in reciept.php, the following can be used:

1
<?php echo shopp('purchase','cardtype','return=1'); ?>

Getting subcategory totals [shopp(‘subcategory’,’total’)] to work in Shopp Plugin 1.1.*

Problem: Pulling the total number of products from a subcat in Shopp doesn’t seem to work out the box. For example, this code WON’T return the total even though the correct tag shopp(‘subcategory’,’total’) is used: Continue reading “Getting subcategory totals [shopp(‘subcategory’,’total’)] to work in Shopp Plugin 1.1.*”

Capture last viewed category in product view in Shopp Plugin for WordPress

Problem: I’m using the Shopp 1.1.9 ecommerce plugin for WordPress, and my client wanted to display specific background images while showing certain products. Shopp is very complete, but one thing that is missing in the current version ‘out of the box’ is the ability to pull the ‘last viewed’ category name when viewing a product. Obviously a product can belong to more than one cat, so it can’t know which one to display… Continue reading “Capture last viewed category in product view in Shopp Plugin for WordPress”

Add ‘Related Products’ to the Product Template in the Shopp WordPress Plugin

Problem: Today I needed to add some code to a Shopp (ver 1.1.9) product.php template so that related products (that have same ‘Tag’) would show up at the bottom. The ‘Related Products‘ template tag was not behaving as I expected it to.. i.e. it was stopping the product page rendering anything at all. Continue reading “Add ‘Related Products’ to the Product Template in the Shopp WordPress Plugin”

Add ‘Drafts’ sorting to Shopp Products list

Problem: There is no ‘drafts’ view filter in the Shopp (>1.1.9) Product Manager, i.e you can’t quickly list all the products that have ‘draft’ status in one go.

Fix: I made this mod to answer a question in the Shopp Helpdesk forum, it’s not very tested, but seems to work perfectly!

Open ‘wp-content/plugins/shopp/core/flow/Warehouse.php’ and replace this:

198
$subfilters = array('f' => 'featured','p' => 'published','s' => 'onsale','i' => 'inventory');

With this:

198
$subfilters = array('f' => 'featured','p' => 'published','d' => 'draft','s' => 'onsale','i' => 'inventory');

Then in the same file replace this:

199
200
201
202
203
204
205
$subs = array(
'all' => array('label' => __('All','Shopp'),'columns' => "count(distinct pd.id) AS total",'where'=>'true'),
'published' => array('label' => __('Published','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pd.status='publish'",'request' => 'p'),
'onsale' => array('label' => __('On Sale','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pt.sale='on'",'request' => 's'),
'featured' => array('label' => __('Featured','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pd.featured='on'",'request' => 'f'),
'inventory' => array('label' => __('Inventory','Shopp'),'total' => 0,'columns' => "count(distinct pt.id) AS total",'where'=>"pt.inventory='on' AND pt.type!='N/A'",'grouping'=>'pt.id','request' => 'i')
);

With this:

199
200
201
202
203
204
205
206
$subs = array(
'all' => array('label' => __('All','Shopp'),'columns' => "count(distinct pd.id) AS total",'where'=>'true'),
'published' => array('label' => __('Published','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pd.status='publish'",'request' => 'p'),
'draft' => array('label' => __('Draft','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pd.status='draft'",'request' => 'd'),
'onsale' => array('label' => __('On Sale','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pt.sale='on'",'request' => 's'),
'featured' => array('label' => __('Featured','Shopp'),'total' => 0,'columns' => "count(distinct pd.id) AS total",'where'=>"pd.featured='on'",'request' => 'f'),
'inventory' => array('label' => __('Inventory','Shopp'),'total' => 0,'columns' => "count(distinct pt.id) AS total",'where'=>"pt.inventory='on' AND pt.type!='N/A'",'grouping'=>'pt.id','request' => 'i')
);

Hopefully this will be included in a future version of Shopp.