Descriptive Minicart Display

This little mod, that i think should be incorperated into CS-Cart, because i hate having to go through a checkout just to find out the total cost.



Will do a bit more with this when 1.3.4 is released



include/cart_status.php



//
// $Id: cart_status.php 751 2005-10-13 11:20:41Z zeke $
//

if ( !defined('IN_CSCART') ) { die('Access denied'); }

sess_register('cart');
$cart['amount'] = @empty($cart['amount']) ? 0 : $cart['amount'];
$cart['subtotal'] = @empty($cart['subtotal']) ? 0 : $cart['subtotal'];
$cart['discount'] = @empty($cart['discount']) ? 0 : $cart['discount'];
$cart['discounted_subtotal'] = @empty($cart['discounted_subtotal']) ? 0 : $cart['discounted_subtotal'];
$cart['tax_subtotal'] = @empty($cart['tax_subtotal']) ? 0 : $cart['tax_subtotal'];
$cart['shipping_rates'] = @empty($cart['shipping_rates']) ? 0 : $cart['shipping_rates'];
$cart['total'] = @empty($cart['total']) ? 0 : $cart['total'];

$smarty->assign_by_ref('cart_amount', @$cart['amount']);
$smarty->assign_by_ref('cart_subtotal', @$cart['subtotal']);
$smarty->assign_by_ref('cart_discount', @$cart['discount']);
$smarty->assign_by_ref('cart_discounted_subtotal', @$cart['discounted_subtotal']);
$smarty->assign_by_ref('cart_tax_subtotal', @$cart['tax_subtotal']);
extract(fn_calculate_cart_content($cart, $auth, true, true, 'I'));
$smarty->assign_by_ref('cart_shipping_rates', @$cart['shipping_rates']);
$smarty->assign_by_ref('cart_total', @$cart['total']);

?>


customer/cart_pages/cart_status.tpl


```php

{* $Id: cart_status.tpl 675 2005-10-04 11:25:33Z lantan $ *}









{if $cart_amount}

{else}

{/if}

{if $cart_amount}
{$lang.products}: {$cart_amount}






























{else}
{$lang.cart_is_empty}
{/if}

{$lang.subtotal}: {include file="common_templates/price.tpl" value=$cart_subtotal}
{$lang.discount}: {include file="common_templates/price.tpl" value=$cart_discount}
{$lang.discounted_subtotal}: {include file="common_templates/price.tpl" value=$cart_discounted_subtotal}
{$lang.taxed_subtotal}: {include file="common_templates/price.tpl" value=$cart_tax_subtotal}
{$lang.total_cost}: {include file="common_templates/price.tpl" value=$cart_total}





```
include/cart.php
Find this code:

```php
if (!empty($cart)) {
extract(fn_calculate_cart_content($cart, $auth, false, false));
if ($settings['General']['images_location'] == 'filesystem') {
if (is_array($cart_products))
foreach($cart_products as $k => $v) {
// Get icon image data
$cart_products[$k]['icon'] = fn_get_image($v['product_id'], 'product', '', true, false);
}
}
if (is_array(@$cart_products)) {
foreach($cart_products as $k => $v) {
// Get product discounts
$discounts = fn_get_product_discount($v['product_id'], $v['price'], 'separate', $auth);
$discount[$k] = @$discounts;
```
Edit these lines:

```php
if (!empty($cart)) {
[COLOR=Red]extract(fn_calculate_cart_content($cart, $auth, true, true, 'I'));
// extract(fn_calculate_cart_content($cart, $auth, false, false));[/COLOR]
if ($settings['General']['images_location'] == 'filesystem') {
if (is_array($cart_products))
foreach($cart_products as $k => $v) {
// Get icon image data
$cart_products[$k]['icon'] = fn_get_image($v['product_id'], 'product', '', true, false);
}
}
```
customer/cart_pages/cart.tpl
Find this code:

```php
{if ($cart.discount|floatval)}

{$lang.discount}:


{include file="common_templates/price.tpl" value=$cart.discount}


{$lang.discounted_subtotal}:


{include file="common_templates/price.tpl" value=$cart.discounted_subtotal}

```
Add this

```php
{if ($cart.discount|floatval)}

{$lang.discount}:


{include file="common_templates/price.tpl" value=$cart.discount}


{$lang.discounted_subtotal}:


{include file="common_templates/price.tpl" value=$cart.discounted_subtotal}

[COLOR=Red]
{$lang.total_cost}:


{include file="common_templates/price.tpl" value=$cart_total}
[/COLOR]
{/if}

```

minicart.gif

[quote name=‘zardos’]Who would be interested in this little mod, that i think should be incorperated into CS-Cart, because i hate having to go through a checkout just to find out the total cost.



You should be able to see this at all times. Anyway if you are interested, and able to help me finnish it off i will post the code.



There is just one or two areas that i am stuck with, (the shipping cost is one) it will show in the minicart when you enter the checkout, but it needs to show as the rest do all the time. Hope you can help.[/QUOTE]To get the postage cost requires the user entering their 5 digit zipcode and country for USPS, in addition to city and state for UPS and FedEx. It is possible to just use Zipcode and Country, but it will require a mod to populate $auth which contains the user’s address. Before checkout or login, the $auth variable isn’t set so you will need the user to input this. Maybe an input field for zip code and dropdown for country in your side box?

The mod looks great! Unfortunately, the way CS-Cart is currently setup is that the shipping calculations don’t take place until the shipping data is completed in checkout.



I am hoping that the developers will move that capability to the cart itself and calculate the shipping when the customer enters a country / zip code / whatever is needed. I know many customers will abandon a cart if they must setup an account before being able to get a shipping quote.



With a shipping estimator in the cart, once the customer enters a zip code, it can be carried around in a session variable and used in the mini-cart. Maybe we can convince the developers to add that functionality into the cart, perhaps even in 1.3.4?

Hi compernicus and sculptingstudio



Lets hope they do add this functionality, until then i’ll keep trying.



Thanks

[quote name=‘zardos’]Hi compernicus and sculptingstudio



Lets hope they do add this functionality, until then i’ll keep trying.



Thanks[/QUOTE]Once you get the zip code and country populate into the variable $auth, you’ll want to call fn_calculate_cart(). I’m assuming you are using cart.php. Remember to change the 3rd parameter to true to tell the function to calculate shipping. Your shipping rates will be found in the array $shipping_rates. They do an extract after the function call so $shipping_rates will be part of your symbol table.

thats a great mod, id use it. not sure how i could help with the development, i suck at this code stuff LOL

Calculating shipping costs in the cart really should be a high priority, hopefully for the final 1.3.4 release. I agree that you can lose many customers by not providing at least an estimate of total order costs before they have to enter personal information.



At least for US shops, limiting required customer input to zip code would be preferable, as the more obstacles you put in their way the more likely it is they’ll abandon their order. I’m not sure how European carriers calculate shipping.

[quote name=‘arlen’]Calculating shipping costs in the cart really should be a high priority, hopefully for the final 1.3.4 release. I agree that you can lose many customers by not providing at least an estimate of total order costs before they have to enter personal information.



At least for US shops, limiting required customer input to zip code would be preferable, as the more obstacles you put in their way the more likely it is they’ll abandon their order. I’m not sure how European carriers calculate shipping.[/QUOTE]



I’m totaly agree!

[quote name=‘zardos’]and able to help me finnish it off[/QUOTE]

I can help with the code, also last I heard we may be able to calculate shipping costs at the cart but ETA is not set…

OK lets see if we can get this working.



First file is /include/customer/cart_status.php



//
// $Id: cart_status.php 751 2005-10-13 11:20:41Z zeke $
//

if ( !defined('IN_CSCART') ) { die('Access denied'); }

sess_register('cart');
$cart['amount'] = @empty($cart['amount']) ? 0 : $cart['amount'];
$cart['subtotal'] = @empty($cart['subtotal']) ? 0 : $cart['subtotal'];
$cart['discount'] = @empty($cart['discount']) ? 0 : $cart['discount'];
$cart['discounted_subtotal'] = @empty($cart['discounted_subtotal']) ? 0 : $cart['discounted_subtotal'];
$cart['tax_subtotal'] = @empty($cart['tax_subtotal']) ? 0 : $cart['tax_subtotal'];
$cart['shipping_cost'] = @empty($cart['shipping_cost']) ? 0 : $cart['shipping_cost'];
$cart['total'] = @empty($cart['total']) ? 0 : $cart['total'];

$smarty->assign_by_ref('cart_amount', @$cart['amount']);
$smarty->assign_by_ref('cart_subtotal', @$cart['subtotal']);
$smarty->assign_by_ref('cart_discount', @$cart['discount']);
$smarty->assign_by_ref('cart_discounted_subtotal', @$cart['discounted_subtotal']);
$smarty->assign_by_ref('cart_tax_subtotal', @$cart['tax_subtotal']);
// $smarty->assign('shipping_rates', @$shipping_rates);
$smarty->assign_by_ref('cart_shipping_cost', @$cart['shipping_cost']);
$smarty->assign_by_ref('cart_total', @$cart['total']);

?>


Second file is skins/your_skin/customer/cart_pages/cart_status.tpl


```php

{* $Id: cart_status.tpl 675 2005-10-04 11:25:33Z lantan $ *}









{if $cart_amount}

{else}

{/if}

{if $cart_amount}
{$lang.products}: {$cart_amount}



































{else}
{$lang.cart_is_empty}
{/if}

{$lang.subtotal}: {include file="common_templates/price.tpl" value=$cart_subtotal}
{$lang.discount}: {include file="common_templates/price.tpl" value=$cart_discount}
{$lang.discounted_subtotal}: {include file="common_templates/price.tpl" value=$cart_discounted_subtotal}
{$lang.taxed_subtotal}: {include file="common_templates/price.tpl" value=$cart_tax_subtotal}
{$lang.selected_shipping_method_cost}: {include file="common_templates/price.tpl" value=$cart_shipping_cost}
{$lang.total_cost}: {include file="common_templates/price.tpl" value=$cart_total}



```
This is as far as i have got, "[COLOR=Red]Please Donate[/COLOR]" Thanks

[quote name=‘zardos’]OK lets see if we can get this working.[/QUOTE]I’ll take a stab at it.



Question. Since you are in the UK, does Royal Mail have an API for real time shipping quotes? If so, do they require a postal code?

Hi sculptingstudio



Thanks, no royal mail don’t have real time API yet that i no of, but you do need a post code, but that does not need to incorperated into any cart system to calculate postal costs.



Thanks Again

Getting close, got it to calculate the shipping on all pages, but without showing the shipping cost, which in this case it is £39.00. :rolleyes:

mini.gif

[quote name=‘sculptingstudio’]I’ll take a stab at it.[/QUOTE]Ok, I’ve got it working. I just need to do a little clean-up and testing.

Hi sculptingstudio



Thanks for digging in on this Larry.

[quote name=‘zardos’]Hi sculptingstudio



Thanks for digging in on this Larry.[/QUOTE]



Guys, this is AWESOME! I would love to incorporate that into my shop when you get it working…just awesome and great work everyone!!!



Cheers,

Travis

:smiley:

[quote name=‘travis@blueheronbags.com’]Guys, this is AWESOME! I would love to incorporate that into my shop when you get it working…just awesome and great work everyone!!![/QUOTE]I’m stuck at the moment because my name server (network soultions) is down.

use the ip address?

[quote name=‘ETInteractive’]use the ip address?[/QUOTE]I was, but it seems to be back.

OK that is it for me on the minicart for 1.3.3 done.



I will wait for finnished 1.3.4 and add a little more to it, like short product description and others just to get by for now, but would like see CS-Cart incorperate this in future release as it is needed and there coding will be far better than mine. :smiley:

minicart3.gif