Experimental project

This is a sandbox project, which contains experimental code for developer use only.

A compact block for Cart / Shopping Basket

When all you need is a simple one liner:

Your cart contains 3 items. Total:£32.50 [ View Cart ] - [ Checkout ]


Featuring

  • Total and quantity
  • No use of views
  • Both cart and empty cart use a template file
  • Translatable messages

Other notes:
The module counts and totals 'product' line items, so shipping cost are excluded.
Simple templates are provided to enable theming.
Variables are provided for:

$quantity
the number of products in the cart
$cart_total
this contains the total + currency (formatted)
$order
The full order object for the shopping cart.
$currency_code
the currency of the current order
$order_total
the total of the order (unformatted)

The most commonly used are: $quantity and $cart_total
Note that the cart_total is formatted for the order currency.
The templates provided also create two variables for messages:

$cart_quantity_msg
e.g. your cart contains 3 items
$cart_total_msg
e.g. Total: £34.50

Message 'templates' are provided to sanitise and translate the cart messages:

$cart_quantity_msg = t('Your Shopping Bag contains %quantity item(s)', array('%quantity' => $quantity)) ;  
    $cart_total_msg = t('Total %cart_total', array('%cart_total' => $cart_total)) ;

References:

We got the inspiration for this module from:

  1. Ryans Szrama's great work here: http://api.drupalcommerce.org/api/Drupal%20Commerce/sites--all--modules-...
  2. This post thread by Magicmyth and userfriendly

Cheers guys!!

Project information

  • Created by guy_schneerson on , updated