GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Dancer2::Plugin::Interchange6::Cart(3) User Contributed Perl Documentation Dancer2::Plugin::Interchange6::Cart(3)

Dancer2::Plugin::Interchange6::Cart

Extends Interchange6::Cart to tie cart to Interchange6::Schema::Result::Cart.

See "ATTRIBUTES" in Interchange6::Cart for a full list of attributes inherited by this module.

Dancer2::Plugin::Interchange6 plugin instance.

Dancer2 app instance for "plugin".

The database name as defined in the Dancer2::Plugin::DBIC configuration.

Defaults to 'default'.

"dbic_cart" related resultset "cart_products" with prefetched "product".

DBIC schema for "database".

Extends inherited "id" in Interchange6::Cart attribute.

Defaults to "id" of "dbic_cart".

Inherited. Default is Dancer2::Plugin::Interchange6::Cart::Product.

Extends inherited sessions_id attribute.

Defaults to "session->id".

See "METHODS" in Interchange6::Cart for a full list of methods inherited by this module.

Load existing cart from the database along with any products it contains.

Add one or more products to the cart.

Possible arguments:

  • single product sku (scalar value)
  • hashref with keys 'sku' and 'quantity' (quantity is optional and defaults to 1)
  • an array reference of either of the above

In list context returns an array of Interchange6::Cart::Products and in scalar context returns an array reference of the same.

Removes all products from the cart.

Pulls old cart items into current cart - used after user login.

Remove single product from the cart. Takes SKU of product to identify the product.

Rename this cart. This is the writer method for "name" in Interchange6::Cart.

Arguments: new name

Returns: new name

Writer method for "sessions_id" in Interchange6::Cart.

Writer method for "users_id" in Interchange6::Cart.

Update quantity of products in the cart.

Parameters are pairs of SKUs and quantities, e.g.

  $cart->update(9780977920174 => 5,
                9780596004927 => 3);

Triggers before_cart_update and after_cart_update hooks.

A quantity of zero is equivalent to removing this product, so in this case the remove hooks will be invoked instead of the update hooks.

Returns updated products that are still in the cart. Products removed via quantity 0 or products for which quantity has not changed will not be returned.

The following hooks are available:
before_cart_add_validate
Executed in "add" before arguments are validated as being valid. Hook receives the following arguments:

Receives: $cart, \%args

The args are those that were passed to add.

Example:

    hook before_cart_add_validate => sub {
        my ( $cart, $args ) = @_;
        foreach my $arg ( @$args ) {
            my $sku = ref($arg) eq 'HASH' ? $arg->{sku} : $arg;
            die "bad product" if $sku eq "bad sku";
        }
    }
    
before_cart_add
Called in "add" immediately before the products are added to the cart.

Receives: $cart, \@products

The products arrary ref contains simple hash references that will be passed to "new" in Interchange6::Cart::Product.

after_cart_add
Called in "add" after products have been added to the cart.

Receives: $cart, \@products

The products arrary ref contains Interchange6::Cart::Products.

before_cart_remove_validate
Called at start of "remove" before arg has been validated.

Receives: $cart, $sku

before_cart_remove
Called in "remove" before validated product is removed from cart.

Receives: $cart, $sku

after_cart_remove
Called in "remove" after product has been removed from cart.

Receives: $cart, $sku

before_cart_update
Executed for each pair of sku/quantity passed to update before the update is performed.

Receives: $cart, $sku, $quantity

A quantity of zero is equivalent to removing this product, so in this case the remove hooks will be invoked instead of the update hooks.

after_cart_update
Executed for each pair of sku/quantity passed to update after the update is performed.

Receives: $product, $sku, $quantity

Where $product is the Interchange6::Cart::Product returned from "update" in Interchange6::Cart::Product.

A quantity of zero is equivalent to removing this product, so in this case the remove hooks will be invoked instead of the update hooks.

before_cart_clear
Executed in "clear" before the clear is performed.

Receives: $cart

after_cart_clear
Executed in "clear" after the clear is performed.

Receives: $cart

before_cart_set_users_id
Executed in set_users_id before users_id is updated.

Receives: $cart, $userid

after_cart_set_users_id
Executed in set_users_id after users_id is updated.

Receives: $new_usersid, $requested_userid

before_cart_set_sessions_id
Executed in set_sessions_id before sessions_id is updated.

Receives: $cart, $sessionid

after_cart_set_sessions_id
Executed in set_sessions_id after sessions_id is updated.

Receives: $cart, $sessionid

before_cart_rename
Executed in "rename" before cart "name" in Interchange6::Cart is updated.

Receives: $cart, $old_name, $new_name

after_cart_rename
Executed in "rename" after cart "name" in Interchange6::Cart is updated.

Receives: $cart, $old_name, $new_name

 Stefan Hornburg (Racke), <racke@linuxia.de>
 Peter Mottram (SysPete), <peter@sysnix.com>

Copyright 2011-2016 Stefan Hornburg (Racke) <racke@linuxia.de>.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

2016-07-06 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.