The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Interchange6::Cart::Product - Cart product class for Interchange6 Shop Machine

DESCRIPTION

Cart product class for Interchange6.

See Interchange6::Role::Costs for details of cost attributes and methods.

ATTRIBUTES

See also "ATTRIBUTES" in Interchange6::Role::Costs.

Each cart product has the following attributes:

id

Can be used by subclasses, e.g. primary key value for cart products in the database.

cart

A reference to the Cart object that this Cart::Product belongs to.

Writer: set_cart

name

Product name is required.

price

Product price is required and a positive number or zero.

Price is required, because you want to maintain the price that was valid at the time of adding to the cart. Should the price in the shop change in the meantime, it will maintain this price.

Writer: set_price

selling_price

Selling price is the price after group pricing, tier pricing or promotional discounts have been applied. If it is not set then it defaults to "price".

Writer: set_selling_price

discount_percent

This is the integer discount percentage calculated from the difference between "price" and "selling_price". This attribute should not normally be set since as it is a calculated value.

"discount_percent" is cleared if either "set_price" or set_selling_price methods are called.

quantity

Product quantity is optional and has to be a natural number greater than zero. Default for quantity is 1.

sku

Unique product identifier is required.

canonical_sku

If this product is a variant of a "parent" product then canonical_sku is the sku of the parent product.

subtotal

Subtotal calculated as "price" * "quantity". Lazy set via builder.

uri

Product uri

weight

Weight of quantity 1 of this product.

extra

Hash reference of extra things the cart product might want to store such as:

  • variant attributes in order to be able to change variant within cart

  • simple attributes to allow display of them within cart

combine

Indicate whether products with the same SKU should be combined in the Cart

Writer: combine

METHODS

See also "METHODS" in Interchange6::Role::Costs.

"extra" methods

"subtotal" methods

is_variant

Returns 1 if "canonical_sku" is defined else 0.

is_canonical

Returns 0 if "canonical_sku" is defined else 1.

should_combine_by_sku

Determines whether a product should be combined by sku based on the value of "combine".

If "combine" isa CodeRef the result of applying that CodeRef is returned otherwise: Returns 0 if a product should not be combined Returns 1 if a product should be combined