How do I add the show/hide visibility template tag to my template files?
This tutorial assumes you have WP e-Commerce 3.8.8 or above installed and activated within your WordPress site. It also assumes you have copied the WP e-Commerce template files to your WordPress Theme directory by following the steps explained on Settings > Store > Presentation within the WordPress Administration.
To toggle visibility of Products via the Show/Hide Products dropdown you must add a conditional template tag to the Products Page and Single Product detail template files. Since we’re using a conditional template tag you can choose to show/hide different elements or the whole Product entirely. This tutorial assumes you wish to hide the Price, Add to Cart and Quantity elements. To do this:
- Open your current WordPress Theme directory with your preferred FTP manager, by default this is: /wp-content/themes/[…]/…
- Open wpsc-products_page.php, this is the Products Page template file which we will be adding our conditional template tag to.
- Find the line starting ‘<form […]>’ (this is line #126 in WP e-Commerce 3.8.8.3)
- Above this line add a new line pasting the following:
<?php if( wpsc_wp_is_product_visible() ) : ?>
- Find the line starting ‘<form><!–close product_form–>’ (this is line #216 in WP e-Commerce 3.8.8.3)
- Below this line add a new line pasting the following:
<?php endif; ?>
- Save and upload changes to wpsc-products_page.php
- Open wpsc-single_product.php, this is the Single Product template file which we will be adding our conditional template tag to.
- Find the line starting ‘<form […]>’ (this is line #77 in WP e-Commerce 3.8.8.3)
- Above this line add a new line pasting the following:
<?php if( wpsc_wp_is_product_visible() ) : ?>
- Find the line starting ‘</form><!–close product_form–>’ (this is line #193 in WP e-Commerce 3.8.8.3)
- Below this line add a new line pasting the following:
<?php endif; ?>
- Save and upload changes to wpsc-single_product.php
Note: If you are using Gold Cart’s Grid view or Product list view you will need to also add this conditional template tag to wpsc-grid_view.php and wpsc-list_view.php respectively.