Cart Item Tags

From Shopp Documentation

Jump to: navigation, search

The CartItem tags are used to show specific information about an item in the shopping cart. They are used in the cart-items loop – a markup structure that goes through each of the items currently in the shopper's cart.

You might notice that once in the cart they are called items. In the catalog, they are called products. This distinction helps to differentiate between a product that has variations and a cart item which is a selected product where the variation has been chosen. Cart items don't work quite the same as products though they have a lot of similar information.

Contents

name

Overview

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

Displays the name of the item. This value is copied from the selected product when it was added to the cart.

Options

  • None

url

Overview

<?php shopp('cartitem','url'); ?>

Displays the URL of the product the item came from.

Options

  • None

sku

Overview

<?php shopp('cartitem','sku'); ?>

Displays the SKU of the item (if available).

Options

  • None

unitprice

Overview

<?php shopp('cartitem','unitprice'); ?>

Displays the unit price in the store's default currency.

Options

  • currency: Default is on. Can be set to on to show the amount in the store's default currency or off to just show the numeric value.
  • taxes: Default is off. Can be set to on to display taxes included in the unit price.

total

Overview

<?php shopp('cartitem','total'); ?>

Displays the cart item's total price in the store's default currency. The cart item total is calculated by multiplying the cart item's quantity by the unit price.

Options

  • currency: Default is on. Can be set to on to show the amount in the store's default currency or off to just show the numeric value.
  • taxes: Default is off. Can be set to on to display taxes included in the unit price.

tax

Overview

<?php shopp('cartitem','tax'); ?>

Displays the tax calculated on the item (if available). Tax can only be calculated when the shipping destination is known.

Options

  • currency: Default is on. Can be set to on to show the amount in the store's default currency or off to just show the numeric value.

quantity

Overview

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

Displays the quantity of the cart item. This tag has several options that can change how it is displayed. By default the tag by itself without options will just show the quantity as a number.

Options

  • input: Default is not set. Set the value to on to display the cart item quantity as an input field that will allow the quantity to be changed by the shopper.
  • class: Default is not set. Allows you to specify a custom class for the quantity input field. Only applies when the tag is being shown as an input field.
  • title: Default is not set. Sets the title of the quantity input field. Only applies when the tag is being shown as an input field.
  • size: Default is 5. Sets the size of the quantity input field. Only applies when the tag is being shown as an input field.

remove

Overview

<?php shopp('cartitem','remove'); ?>

Displays a control element that can be displayed as a link or a <button> element that when clicked will remove the item from the cart.

Options

  • label: Default is Remove. Sets the label text used for the link or on the button.
  • class: Default is not set. Allows you to specify a custom class for the link or the button.
  • input: Default is not set. Set the value to button to display as a button. Omit the input option to display as a link. (Remove this from the tag if you are having issues with IE).
  • title: Default is not set. Sets the title of the quantity input field. Only applies when the tag is being shown as an input field.
  • size: Default is 5. Sets the size of the quantity input field. Only applies when the tag is being shown as an input field.

options

Overview

<?php shopp('cartitem','options'); ?>

Displays the currently selected product variation for the item or displays a drop-down menu that allows the shopper to change the selected product variation of the item. The shopper must click the update button shopp('cart','update-button') in order for the change to be set and to get the pricing updates to recalculate the cart.

Options

  • show: Default is menu. Set to selected to display the currently selected cart item option name as plain text. Set to menu to display as a drop-down menu.
  • before: Text to be displayed before the selected option name or options menu.
  • after: Text to be displayed after the selected option name or option menu.
  • class: Default is not set. Allows you to specify a custom class for the options menu.

inputs-list

Overview

<?php shopp('cartitem','inputs-list'); ?>

Displays all of the custom inputs for the cart item in an unordered list (<ul>).

Options

  • before: Text or markup to be displayed before inputs list.
  • after: Text or markup to be displayed after the inputs list.
  • class: Default is (empty). Allows you to specify a custom class for the <ul> element.
  • exclude: Used to specify names of inputs to exclude from displaying in the list. Multiple inputs can be excluded by separating them with a comma: Input Name 1,Input Name2….

hasinputs

Overview

<?php if(shopp('cartitem','hasinputs')) {} ?>

Tests whether the cart item has any custom inputs.

Options

  • None

Examples

Display the list of cart item inputs
<?php if(shopp('cartitem','hasinputs')): ?>
	<ul>
	<?php while(shopp('cartitem','inputs')): ?>
		<li><?php shopp('cartitem','input','name'); ?>: <?php shopp('cartitem','input'); ?></li>
	<?php endwhile; ?>
	</ul>
<?php endif; ?>

This example generates a listing identical to the output created by shopp('cartitem','inputs-list') and provides a base of reference for creating custom markup listings.

inputs

Overview

<?php while(shopp('cartitem','inputs')) {} ?>

Loops through each cart item input so that a custom input 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

Display the list of cart item inputs
<?php if(shopp('cartitem','hasinputs')): ?>
	<ul>
	<?php while(shopp('cartitem','inputs')): ?>
		<li><?php shopp('cartitem','input','name'); ?>: <?php shopp('cartitem','input'); ?></li>
	<?php endwhile; ?>
	</ul>
<?php endif; ?>

This example generates a listing identical to the output created by shopp('cartitem','inputs-list') and provides a base of reference for creating custom markup listings.

input

Overview

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

Used in the 'inputs' loop to show an individual cart item input. With no options specified, this tag displays the value of the input.

Options

  • name: Displays the name of the cart item input.

Examples

Display the list of cart item inputs
<?php if(shopp('cartitem','hasinputs')): ?>
	<ul>
	<?php while(shopp('cartitem','inputs')): ?>
		<li><?php shopp('cartitem','input','name'); ?>: <?php shopp('cartitem','input'); ?></li>
	<?php endwhile; ?>
	</ul>
<?php endif; ?>

This example generates a listing identical to the output created by shopp('cartitem','inputs-list') and provides a base of reference for creating custom markup listings.

thumbnail

Overview

<?php shopp('cartitem','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 thumbnail <img> element.
  • width: Set the thumbnail width property.
  • height: Set the thumbnail width property.

Examples

Display a 32*32 pixels thumbnail
<?php shopp('cartitem','thumbnail','width=32&height=32'); ?>