NAME
Business::Cart::Generic::Database::Order - Basic shopping cart
Synopsis
Description
Business::Cart::Generic implements parts of osCommerce and PrestaShop in Perl.
Installation
Constructor and Initialization
Parentage
This class extends Business::Cart::Generic::Database::Base.
Using new()
new()
is called as my($obj) = Business::Cart::Generic::Database::Order -> new(k1 => v1, k2 => v2, ...)
.
It returns a new object of type Business::Cart::Generic::Database::Order
. See Business::Cart::Generic::Database.
Key-value pairs accepted in the parameter list:
- o db => $db
-
Takes an object of type Business::Cart::Generic::Database.
This key => value pair is mandatory.
- o schema => $schema
-
Takes a DBIx::Class schema object.
This value is provided by the parent, Business::Cart::Generic::Database::Base.
These keys are also getter-type methods.
Methods
add_to_cart($order)
Add an item to the cart.
$order is a hashref returned by Business::Cart::Generic::Util::Validator.
Returns the order hashref from the session object.
This latter hashref is discussed in the FAQ in Business::Cart::Generic. The code is in "reset_order()" in Business::Cart::Generic::Database.
cancel_order()
Cancel the order whose id is in the order hashref in the session object.
Returns nothing.
checkout()
Wrap up the order by calculating quantities on hand per item, and updating the order history.
Returns nothing.
get_orders($limit)
Get order item objects from the orders table.
These items are of type DBIx::Class::Row.
Limit defaults to {}, and can be used to get 1 order by - e.g. - setting it to {'me.id' => $order_id}.
The orders table is joined with these tables:
- o The billing_address
-
I.e. the street_addresses table.
- o The customers table
- o The customer_address
-
I.e. the street_addresses table.
- o The delivery_address
-
I.e. the street_addresses table.
- o The order_statuses table
- o The payment_methods table
inflate_order($order)
$order is of type DBIx::Class::Row.
Returns a hashref with these keys:
- o billing_address
-
This is a hashref with these keys:
The values are all strings.
- o customer
-
This is a hashref with these keys:
The values are all strings.
- o customer_address
-
This is a hashref with these keys:
The values are all strings.
- o delivery_address
-
This is a hashref with these keys:
The values are all strings.
- o date_added
-
This is a string like '2011-05-10 10:48:53'.
- o date_completed
-
This is a string like '2011-05-10 10:48:53'.
- o id
-
This is the order's primary key in the orders table.
- o item
-
This is an array ref of item hashrefs, with these keys:
- o currency_id
-
This is the currency's primary key in the currencies table.
- o description
-
This is a string from the products table.
- o item_id
-
This is the item's primary key in the items table.
- o name
-
This is a string from the products table.
- o order_id
-
This is the order's primary key in the orders table.
- o price
-
This is a float from the products table.
- o product_id
-
This is the product's primary key in the products table.
- o quantity
-
This is an integer from the items table.
- o tax_rate
-
This is a float from the products table.
- o order_status
-
This is a string from the order_statuses table.
- o payment_method
-
This is a string from the payment_methods table.
- o total_price
-
This is a sum over all items.
- o total_quantity
-
This is a sum over all items.
- o total_tax
-
This is a sum over all items.
remove_from_cart($order_id, $item_id)
Remove an item from the cart.
$order_id is the primary key in the orders table.
$item_id is the primary key in the items table.
save_order($order)
Called by add_to_cart().
$order is a hashref returned by Business::Cart::Generic::Util::Validator.
Returns nothing.
save_order_history($order)
Called by add_to_cart().
$order is a hashref returned by Business::Cart::Generic::Util::Validator.
Returns nothing.
save_order_item($order)
Called by add_to_cart().
$order is a hashref returned by Business::Cart::Generic::Util::Validator.
Returns the primary key in the items table of the newly-inserted item.
Machine-Readable Change Log
The file CHANGES was converted into Changelog.ini by Module::Metadata::Changes.
Version Numbers
Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.
Thanks
Many thanks are due to the people who chose to make osCommerce and PrestaShop, Zen Cart, etc, Open Source.
Support
Email the author, or log a bug on RT:
https://rt.cpan.org/Public/Dist/Display.html?Name=Business::Cart::Generic.
Author
Business::Cart::Generic was written by Ron Savage <ron@savage.net.au> in 2011.
Home page: http://savage.net.au/index.html.
Copyright
Australian copyright (c) 2011, Ron Savage.
All Programs of mine are 'OSI Certified Open Source Software';
you can redistribute them and/or modify them under the terms of
The Artistic License, a copy of which is available at:
http://www.opensource.org/licenses/index.html