Product Tags

From Shopp Documentation

Jump to: navigation, search

Product tags display elements and properties for a specific product and are used in any template that a specific product is being displayed. For the most part, product tags are used in the product.php template file and related.php template file.

Contents

link

Overview

<?php shopp('product','link'); ?>

Outputs a direct link to the product.

Options

  • None

Examples

<a href="<?php shopp('product','link'); ?>"><?php shopp('product','name'); ?></a>

name

Overview

<?php shopp('product','name'); ?>

Displays the name of the product.

Options

  • None

id

Overview

<?php shopp('product','id'); ?>

Displays the product ID from the database.

Options

  • None

slug

Overview

<?php shopp('product','slug'); ?>

Displays the slug of the product.

Options

  • None

summary

Overview

<?php shopp('product','summary'); ?>

Displays the summary of the product.

Options

  • None

description

Overview

<?php shopp('product','description'); ?>

Displays the full description of the product.

Options

  • None

price

Overview

<?php shopp('product','price'); ?>

Displays the normal price of the product using the currency format associated with the store's base of operations (set in the General Settings screen). If there are multiple prices (because of product variations) then a price range is displayed showing the lowest - highest prices. Additionally, if the country of the store's base of operations uses VAT-style taxes, Shopp will automatically include the applicable tax rate to the price. This behavior can be overriden with the taxes option.

Options

  • taxes: Default behavior depends on the base of operations. This setting can override the default. When set to true, includes the tax in the price(s) shown. When set to false, excludes tax from the price(s) displayed.
  • starting: Default is (empty). Displays the smallest price of a price range with the value of this option as the label (e.g. starting=Starting at : Starting at $5.99)

saleprice

Overview

<?php shopp('product','saleprice'); ?>

Displays the sale price of the product using the currency format associated with the store's base of operations (set in the General Settings screen). If there are multiple sale prices (because of product variations) then a sale price range is displayed showing the lowest - highest sale prices that are available. The applicable tax rate is included in the price(s) if the country of the store's base of operations uses VAT-style taxes. This behavior can be overriden with the taxes option.

Options

  • taxes: Default behavior depends on the base of operations. This setting can override the default. When set to true, includes the tax in the price(s) shown. When set to false, excludes tax from the price(s) displayed.
  • starting: Default is (empty). Displays the smallest price of a price range with the value of this option as the label (e.g. starting=Starting at : Starting at $5.99)

onsale

Overview

<?php if(shopp('product','onsale')) {} ?>

A test to determine if there are any active sale prices. Sale prices can be set by adding and enabled a sale price in the product editor, or by any applicable promotions configured in the Promotions manager.

Options

  • None

Examples

<?php if(shopp('product','onsale')): ?>
	…content if the product has any active sale price…
<?php else: ?>
	…content shown if there are no active sale prices…
<?php endif; ?>

has-savings

Overview

<?php if(shopp('product','has-savings')) {} ?>

A test intended to allow you to show a savings amount (a currency amount and/or percentage) when there is a difference between the regular price and sale price of a product.

Options

  • None

Examples

<?php if(shopp('product','has-savings')): ?>
	…content when a savings amount is available…
<?php else: ?>
	…content shown if there are is no savings amount…
<?php endif; ?>

savings

Overview

<?php shopp('product','savings'); ?>

Normally used in the first part of a 'has-savings' test block to show the amount of savings between the sale price and regular price.

Options

  • show: Default is money. Allows you to specify whether to show the amount of savings as a currency amount or percentage. To show as a percent, use show=% or show=percent

freeshipping

Overview

<?php if(shopp('product','freeshipping')) {} ?>

Used in a test to display different content when free shipping is available versus when it is not available for a specific product.

Options

  • None

Examples

<?php if(shopp('product','freeshipping')): ?>
	…content when free shipping is available…
<?php else: ?>
	…content if free shipping is not available…
<?php endif; ?>

isfeatured

Overview

<?php if (shopp('product','isfeatured')) {} ?>

Used to test when a product has been marked as a featured product that would appear in the Featured Products smart category.

Options

  • None

Examples

<?php if (shopp('product','isfeatured')): ?>
	…content to display when the product is featured…
<?php endif; ?>

thumbnail

Overview

<?php shopp('product','thumbnail'); ?>

Displays the default thumbnail for the product. The default thumbnail is the image that is set as the first image when using a custom image order, or which ever image is automatically sorted to be first when using other image order settings set in the Presentation Settings screen.

Options

  • class: Default is (not set). Specifies a CSS class for the thumnail <img> element.

has-images

Overview

<?php if(shopp('product','has-images')) {}  ?>

Tests whether the product has any images of a specified type.

Options

  • type: Default is thumbnail. Used to set what type of images to show in the images loop. Set to small to display the gallery preview size images, or image to display the original, full size images as they were uploaded to your store (note longer download times for the larger images).

Examples

<?php if(shopp('product','has-images')): ?>
	…content shown when product images are available…
<?php else: ?>
	…content shown if no product images are available…
<?php endif; ?>

images

Overview

<?php while(shopp('product','images')) {} ?>

Loops through the product images so that you can display each product image of a set type. This is similar to "The Loop" structure in WordPress for displaying a custom layout for WordPress posts.

Options

  • None

Examples

<?php while(shopp('product','images')): ?>
	…content shown for a specific product image…
<?php endwhile; ?>

image

Overview

<?php shopp('product','image','options…'); ?>

Used in the 'images' loop to show an individual product image of the type set in the loop. Alternatively, you can use the has-images test and this tag to show the default product image of a specific type. The default image for a product is determined by the image sorting options specified in the Presentation Settings.

Options

  • property: Overrides the default output of this tag to display a valid property of the image including any of the following: url, width, height, title, alt, id. If an invalid property is requested, the image id is displayed. Use the return=true option to return the property as PHP data.
  • type: Default is thumbnail. When the tag is used outside of the loop, you can use this option to specify the type of image for the default product image.
  • class No default setting. Allows you to specify a CSS class for the image.
  • zoom: Default is off. When set to on the Thickbox zoom effect is enabled when clicking on the image.
  • zoomfx: Default is (not set). Enables zoom (also known as lightbox) effects for alternate JavaScript-based modal content viewers.
  • width: Set the image width property. If the height option is omitted, setting the width will cause the height to scale proportionally.
  • height: Set the image width property. If the width option is omitted, setting the height will cause the width to scale proportionally.

gallery

Overview

<?php shopp('product','gallery'); ?>

Builds a dynamic image gallery with a gallery preview image display and a selection of thumbnails for all images available for a product. When a thumbnail is clicked by the visitor, the gallery preview gracefully fades to display the selected image. Clicking the gallery preview shows the full image as uploaded by the store owner using the Thickbox modal image viewer.

Options

  • zoomfx: Default is shopp-thickbox. Used to specify an alternative zoom effect provided by a different JavaScript modal image viewer. Requires manual loading of the alternative viewer script in the WordPress theme. Using an alternative viewer does not prevent Shopp's ThickBox implementation from loading.
  • preview: Default is click. Sets the thumbnail trigger action used to show the larger sized preview image above the thumbnails. Can be set to click, dblclick, mouseenter, mouseleave, mousemove, mouseout, mouseover
  • thumbsize: Default is 32. Sets the width and height of the thumbnails in the gallery.
  • thumbwidth: Default is 32. Sets the maximum width of the thumbnails. When no thumbheightoption is specified the height is variable to maintain the aspect ratio of the image. This option overrides the thumbsize option.
  • thumbheight: Default is 32. Sets the maximum height of the thumbnails. When no thumbwidthoption is specified the width is variable to maintain the aspect ratio of the image. This option overrides the thumbsize option.

has-categories

Overview

<?php if(shopp('product','has-categories')) {} ?>

Tests whether the product has any categories it is assigned to.

Options

  • None

Examples

<?php if(shopp('product','has-categories')): ?>
	…content shown when product categories are available…
<?php else: ?>
	…content shown if no product categories are available…
<?php endif; ?>

categories

Overview

<?php while(shopp('product','categories')) {} ?>

Loops through each assigned category so that a custom layout for displaying the categories can be specified within the looping block. This is similar to "The Loop" structure in WordPress for displaying a custom layout for WordPress posts.

Options

  • None

Examples

<?php while(shopp('product','categories')): ?>
	…content shown for a specific product spec…
<?php endwhile; ?>

category

Overview

<?php shopp('product','category'); ?>

Used in the 'categories' loop to show information for each assigned category. On its own, without any options this tag will show the name of the category.

Options

  • show: Default is (not set). Can be set to show the category id or the category slug.

in-category

Overview

<?php if(shopp('product','in-category','id=3')) {} ?>

Used to test whether the product exists in a specified category.

Options

  • id: Specify the category to compare against by the category's ID.
  • slug: Specify the category to test by the category's slug.
  • name: Use the category's name to specify the category to test against.

Examples

<?php if(shopp('product','in-category','id=3')): ?>
	…content to show if the product is in category 3…
<?php endif; ?>

has-specs

Overview

<?php if(shopp('product','has-specs')) {} ?>

Tests whether the product has any detail specs.

Options

  • None

Examples

<?php if(shopp('product','has-specs')): ?>
	…content shown when product specs are available…
<?php else: ?>
	…content shown if no product specs are available…
<?php endif; ?>

specs

Overview

<?php while(shopp('product','specs')) {} ?>

Loops through each product detail spec so that custom spec layout can be specified within the looping block. This is similar to "The Loop" structure in WordPress for displaying a custom layout for WordPress posts.

Options

  • None

Examples

<?php while(shopp('product','specs')): ?>
	…content shown for a specific product spec…
<?php endwhile; ?>

spec

Overview

<?php shopp('product','spec','options…'); ?>

Used in the 'specs' loop to show the individual product detail/spec entry.

Options

  • name: Displays the name of an individual product detail entry.
  • content: Displays the content associated with an individual detail entry.
  • separator: Default is :. Allows you to specify a separation character, string of characters or HTML markup to use between the name and the content of a product detail entry.
  • delimiter: Default is , . Multiple spec entries in a product that share the same name are combined into a list separated by the delimiter option.

has-variations

Overview

<?php if(shopp('product','has-variations')) {} ?>

Used to detect if there are product options available that need to be selected before the product can be added to the cart.

Options

  • None

Examples

<?php if(shopp('product','has-variations')): ?>
	…content shown when product variation options are available…
<?php else: ?>
	…content shown if no product variation options are available…
<?php endif; ?>

variations

Overview

<?php shopp('product','variations'); ?>

By default, this tag loops through each variation of the product available allowing custom display of variation properties through the shopp('product','variation') tag.

Using the mode option this tag can instead display variation selection controls. In single mode it will display a single drop-down menu with each variation as a separate, selectable option. In multiple mode (the default used in the built-in product.php template file), this tag displays multiple menus for each variation option (the options that build to make a single variation) for a more natural option selection experience. In multiple mode, a selection must be made from each menu in order to add the product to the cart. Additionally, the final price of the product cannot be determined until the last option is selected and as such, the price will only be displayed in the last menu.

Options

  • label: Default is on. Displays a label with the name of the menu as entered in the product editor before the menu.
  • mode: Default is multiple. Accepts single or multiple. The mode option allows you to choose between displaying a single drop-down menu with all of the product variation options merged together, or multiple menus with each option set available in separate menus. Note that using multiple menus relies on JavaScript. If your visitor does not use JavaScript, they will not be able to select product variations to add to the cart. If the mode is not set, this tag can be used for looping through individual variations to use the shopp('product','variation') .
  • after_menu: No default value. Allows you to specify a string of characters or HTML markup to display after the the menu is displayed.
  • before_menu: No default value. Allows you to specify a string of characters or HTML markup to display before the label (if enabled) and the menu are displayed.
  • defaults: No default value. Allows you to specify a default option that is displayed as the initial selection for the menu.
  • disabled: Default is show. Shows out-of-stock or disabled variations in the menu but makes them disabled and unable to be selected.
  • required: Default is You must select the options for this item before you can add it to your shopping cart.. Specifies the warning error when attempting to add a product to the cart without selecting all of the necessary variation options.
  • taxes: Default behavior depends on the base of operations. This setting can override the default. When set to true, includes the tax in the price(s) shown. When set to false, excludes tax from the price(s) displayed.

variation

Overview

<?php shopp('product','variation'); ?>

Displays a specified property from the current variation in a shopp('product','variations') loop.

Options

  • id: Displays the database ID of the pricing variation.
  • label: Displays the full label of the variation. The label is built from a comma-separated list of the option names that make up a given variation.
  • type: Displays the type of the pricing variation (e.g. Shipped, Virtual, Download, Donation)
  • sku: Displays the SKU (Stock Keeping Unit) of the product pricing variation.
  • price: Displays the price of the product's variation in the currency format associated with the store's base of operations. The tax behavior of the price is the same as the shopp('product','price') tag and can be overriden by the taxes option.
  • saleprice: Displays the price of the product's variation in the currency format associated with the store's base of operations. The tax behavior of the price is the same as the shopp('product','saleprice') tag and can be overriden by the taxes option.
  • stock: Displays the current stock of the product's pricing variation.
  • weight: Displays the weight of the product's pricing variation.
  • shipfee: Displays the shipping fee of the product's pricing variation in the currency associated with the store's base of operation setting.
  • sale: Returns a boolean true or false value representing whether the product's pricing variation is "on sale". This can be tested against using a PHP if statement.
  • shipping: Returns a boolean true or false value representing whether the product's pricing variation has shipping enabled. Shipping enabled for a pricing variation means shipping costs will be calculated for the product in the cart. This can be tested against using a PHP if statement.
  • tax: Returns a boolean true or false value representing whether the product is taxable. This can be tested against using a PHP if statement.

donation

Overview

<?php shopp('product','donation'); ?>

Displays a donation amount input that can be displayed as either a text box or a drop-down menu that allows the customer to specify an amount to donate.

Options

  • label: No default setting. Specify a label for the input element.
  • labelpos: Default is before. Can be set to display the label before or after the input element.
  • input: Default is text. Can be set to display the input element as a text field or a menu of options. The built-in templates specify menu.
  • value: Default is 1 or the minimum amount specified in the product editor. Specifies the default or selected value for the input. When the input type is set to text the value option shows as the default value. When the input type is set to menu, the value option specifies the default selection from the options.
  • options: Default is 1-15,20,25,30,35,40,45,50,60,70,80,90,100. Specify the options to display for menu type quantity input. Individual options are specified separated by commas (,). You can also specify a range of options using a number range using dashes #-##.

quantity

Overview

<?php shopp('product','quantity'); ?>

Displays a quantity input that can be displayed as either a text box or a drop-down menu that allows the customer to select a quantity of the product before adding it to their cart. When using a drop-down menu on products that have limited stock available, the menu is limited to the stock available. In the case of products with variations, the menu is limited to the maximum stock available from any of the variations.

Options

  • label: No default setting. Specify a label for the input element.
  • labelpos: Default is before. Can be set to display the label before or after the input element.
  • input: Default is text. Can be set to display the input element as a text field or a menu of options. The built-in templates specify menu.
  • value: Default is 1. Specifies the default or selected value for the input. When the input type is set to text the value option shows as the default value. When the input type is set to menu, the value option specifies the selected option.
  • options: Default is 1-15,20,25,30,35,40,45,50,60,70,80,90,100. Specify the options to display for menu type quantity input. Individual options are specified separated by commas (,). You can also specify a range of options using a number range using dashes #-##.

input

Overview

<?php shopp('product','input'); ?>

Displays an input element to allow customer input for a product before adding it to the cart.

Options

  • type: Default is text. Can be set to display the input element as a text,password,hidden,checkbox,radio field, a textarea, or a menu of options.
  • name: No default set. Sets the name of the field to track for the product in the cart and finally in the order.
  • options: No default set. When the type option is set to menu this option specifies the options in the menu separated by commas (,). To specify an option that uses apostrophes (') can be surrounded by quotes ("").
  • cols: No default set. When the type option is set to textarea this option specifies the cols attribute for the <textarea> element.
  • rows: No default set. When the type option is set to textarea this option specifies the rows attribute for the <textarea> element.
  • size: No default set. When the type option is set to text or password this option specifies the size of the input in number of characters.
  • class: No default set. Specify the a custom CSS class for the input element.
  • value: No default set. Specifies the default value for the input element. For text and textarea type inputs, the value option is displayed in the field. For menu type inputs, the value specifies the default selected option out of the options setting.
  • HTML Field Attributes: Supports specifying other standard xHTML/HTML field attributes including: accesskey,alt,checked,disabled,maxlength,readonly,tabindex,title

Examples

<p><label>Engraving: </label><br />
<?php shopp('product','input','type=textarea&name=Engraving&cols=20&rows=3'); ?></p>

addtocart

Overview

<?php shopp('product','addtocart'); ?>

Displays the 'Add to Cart' button that adds the product (and selected product variations) to the shopper's cart.

Options

  • label: Default is Add to Cart. Allows you to change the text used for the button label.
  • ajax: Default is off. Set to on to turn on the AJAX add to cart process. Read more about Customizing the AJAX-enabled Cart.

found

Overview

<?php if(shopp('product','found')) {} ?>

Used to test if the requested product is available. Additionally, this tag can be used to load several extra product details in one consolidated query to the database. Alternatively, if any tags are used to access details not pre-loaded with this tag, they would continue to act normally but would generate an extra query to the database. Where performance is a priority, and details that are known to be needed should be pre-loaded using the load option for this tag.

Options

  • load: Default is prices,images,specs. Used to specify what product data to load ahead of time in a single database query. Accepts multiple options separated by commas including: prices, images, categories, specs, tags. This option is useful for speeding up your store's performance. The tradeoff is that it requires more server memory to process.

Examples

Display a Product
<?php if(shopp('product','found')): ?>
	<h3><?php shopp('product','name'); ?></h3>
<?php else: ?>
	<p>No product found.</p>
<?php endif; ?>

Display a Product and Pre-load All Product Details

<?php if(shopp('product','found','load=prices,images,specs,categories,tags')): ?>
	<h3><?php shopp('product','name'); ?></h3>
<?php else: ?>
	<p>No product found.</p>
<?php endif; ?>

has-tags

Overview

<?php if(shopp('product','has-tags')) {} ?>

Test whether the product has any tags associated with it.

Options

  • None

Examples

<?php if(shopp('product','has-tags')): ?>
	<ul>
	<?php while(shopp('product','tags')): ?>
		<li><?php shopp('product','tag'); ?></li>
	<?php endwhile; ?>
	</ul>
<?php endif; ?>

tags

Overview

<?php while(shopp('product','tags')) {} ?>

Each call iterates to the next tag associated with the product.

Options

  • None

Examples

<?php if(shopp('product','has-tags')): ?>
	<ul>
	<?php while(shopp('product','tags')): ?>
		<li><?php shopp('product','tag'); ?></li>
	<?php endwhile; ?>
	</ul>
<?php endif; ?>

tag

Overview

<?php shopp('product','tag'); ?>

Typically used within tags loop, returns the current tag. The default return with no options is the name of the current tag.

Options

  • show: value of id returns the id of the current tag

Examples

Display a list of tags
<?php if(shopp('product','has-tags')): ?>
	<ul>
	<?php while(shopp('product','tags')): ?>
		<li><?php shopp('product','tag'); ?></li>
	<?php endwhile; ?>
	</ul>
<?php endif; ?>
Display a list of tag IDs
<?php if(shopp('product','has-tags')): ?>
	<ul>
	<?php while(shopp('product','tags')): ?>
		<li><?php shopp('product','tag','show=id'); ?></li>
	<?php endwhile; ?>
	</ul>
<?php endif; ?>

tagged

Overview

<?php if (shopp('product','tagged','name=tagname')) {} ?>

Tests to see if specific tag is associated with the current product, either by name of the tag or its id.

Options

  • name: No default value. Value entered will be tested to match the name of any tag associated with the product.
  • id: No default value. Value entered will be tested to match the tag-id of any tag associated with the product.

Examples

Check if product tagged with 'foo' by ID
<?php if(shopp('product','tagged', 'id=10')) 
	echo "product is tagged foo"; ?>
Check if product tagged with 'bar' by tag name
<?php if(shopp('product','tagged','name=bar')) 
	echo "product tagged bar"; ?>

</div>