Checkout: Shopping Cart Widget

The shopping cart widget can be placed on the front of your site to display an order summary to your customers as they browse your shop. With ‘Add to Cart Ajax’ turned on in the Checkout > Configuration > Shopping Cart, the shopping cart widget will also be updated automatically using Ajax as products are added to the order. Additionally, the shopping cart widget has some useful links in it such as “Orders History” which takes the customer to an orders history section and a “Downloads Management” link which takes the customer to the downloads section.

Configure the widget

2015-08-12_15-19-19

1. Title

The title of the shopping cart widget to be displayed on the front of your site to your users/customers.

2. Display

To use the shopping cart widget, choose ‘Shopping Cart’ for the display.

3. Show (total only/all details)

This setting gives you the ability to simplify the widget by showing the total only which is achieved by selecting ‘Total Only’. The normal, full widget will be displayed if ‘All Details’ is selected.

4. Product Summary

This setting gives you the ability to show a summary of the products in the cart.

5. Show Thumbnail

Set this setting if you want to display a product thumbnail in the product summary

6. Hide when Empty

Enabling this feature (checking the box) will hide the Shopping Cart Widget when the customer has no items in their cart. To disable this feature simply uncheck the box.

7. Enable Coupon Form

By selecting YES you will add a field in your widget in which customers are able to submit a discount/coupon code. These coupon codes can be managed in the Checkout > Coupon COdes section of the plugin. It is your choice how you give these coupon codes to your customers.

Front-end Display

2015-08-12_15-19-01

Hardcode the widget

You can hardcode the shopping cart widget into your WordPress theme with a few simple lines of code. It works just like the normal sidebar widget but you are able to place it where needed on your site’s theme.

if (class_exists('wpCheckout')) {
// Initialize an object of the class
$wpCheckout = new wpCheckout();

//parameters for the widget (see details below)
$parameters = array(
'show' => "normal",
'hide_when_empty' => 0,
'enablecoupons' => "N",
'shlink' => "N",
);

// Output the shopping cart widget
// Use 'show' => "minimal" to display just the total
$wpCheckout -> widget('cart', $parameters);
}

IMPORANT: Be sure to copy the code from the PastebinRAW Paste Data” on the link above instead of copying from this documentation.

Parameters for Hardcoding

  • show = [ ‘normal’ | ‘minimal’ ] (default: ‘normal’) //’minimal’ means it only shows the total.
  • hide_when_empty = [ 1 | 0 ] (default: 0) //set to 1 to hide the widget when empty.
  • enablecoupons = [ ‘Y’ | ‘N’ ] (default: ‘N’) //set to ‘Y’ to show the coupon form.
  • shlink = [ ‘Y’ | ‘N’ ] (default: ‘N’) //set to ‘Y’ to display a link below the widget.
  • shlinktitle = [ <shlinktitle> ] //specify the title/anchor text for your link.
  • shlinkurl = [ <shlinkurl> ] //speicfy the URL for your link.

Shopping Cart Link

You can hardcode the following code into your theme to display a Shopping Cart [x] anywhere in your theme. Where [x] is the amount of items in the Shopping Cart.

if (class_exists('wpCheckout')) {
	$wpCheckout = new wpCheckout();
	global $wpcoDb, $Item, $wpcoHtml, $Order;
	$co_id = $Order -> cart_order();
	$wpcoDb -> model = $Item -> model;
	$count = $wpcoDb -> count(array($co_id["type"] . '_id' => $co_id['id']));
	echo '</pre>
<div class="cartlink"><a href="' . $wpcoHtml -> cart_url() . '">Shopping Cart (' . $count . ')</a></div>
<pre>
';
}

Beautiful Newsletter Templates

Professional newsletter templates that are fully responsive for desktop, tablet, and mobile. They are 100% cross-client compatible.

See Them

Pin It on Pinterest