Category: WordPress

  • 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:

    data->Order->Billing->cardtype; ?>

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

  • Get ID of the WordPress ‘Front Page’ in Theme’s functions.php

    Problem: I wanted to add some Meta Boxes to the homepage only, and have them only visible in WP-Admin when editing that page.

    Solution:  Provided that a page has been selected in wp-admin > General Settings > Reading Settings > A Static Page [Front Page], then this code can be used to pull that value out as a Page ID: (more…)

  • Remove Links menu item in WordPress

    Problem: I’m customising a WP install for a client, adding some Custom Post Types and wotnot, and they aren’t going to have any need for the Links thing.

    Fix: Adding this to your theme’s (or child-theme’s) functions.php removes the page and the menu link: (more…)

  • 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: (more…)

  • Remove prices from Variation drop-downs in Shopp WordPress plugin

    Problem: In Shopp (1.1.9) the default variations drop-down list shows prices. This isn’t always desired. This is the default usage: (more…)

  • 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… (more…)

  • 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. (more…)

  • WordPress replaces double and triple hyphens (– or —)

    Problem: The other day I was trying to type two hypens (–) in a post, and when I saved/published the post, WordPress reformatted the hypens to display as an ‘en dash‘ (–).

    More Info: After some searching about, and some helpful info provided in the WordPress Codex, I found out about a WP function called ‘wptexturize’ which is applied each time a post is rendered. The function – which can be found in ‘wp-includes/formatting.php’ – replaces quite a few things, like ™ to ™ etc.

    Fix: You could stop this happening a number of ways i.e. editing the function to stop it doing the replace altogether, or install a plugin that does it (maybe this one, haven’t tried it!). I decided to use WordPress’s remove_filter function to stop the reformatting taking place.

    To do this, open the ‘functions.php’ file within your theme. If one does not exist, create it.

    Add the following code to the bottom of the file, taking care not to end up with too many or too few <?php tags:

    <?php
    remove_filter('the_content', 'wptexturize');
    remove_filter('the_title', 'wptexturize');
    ?>

    Then save the file (or ‘update’ if you’re doing this via the theme editor in WP admin) and view your post. That should do it! (proof is here, you can only see those double and triple hyphens in this blog post title because I’ve just added the code above to this sites functions.php also!)

  • 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:

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

    With this:

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

    Then in the same file replace this:

    $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:

    $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.