This donated protion adds shipping to your MiniCart. Here are the instructions for installation in 1.3.3-sp2 (make a backup of your files first):
Take the file attached to this post called x.jpg and place it in the folder “skins/yourskin/customer/images/”.
Make your file “skins/yourskin/customer/cart_pages/cart_status.tpl” look like this:
```php
{* $Id: cart_status.tpl 675 2005-10-04 11:25:33Z lantan $ }
{ Minicart mod by Backstrom, inspired by Zardos *}
{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.estimated_shipping}: |
{if $cart_est_ship>0} {include file="common_templates/price.tpl" value=$cart_est_ship} {/if} |
|
{$lang.total_cost}: | {include file="common_templates/price.tpl" value=$cart_est_total} |
{$lang.country}: |
- {$lang.select_country} - {foreach from=$est_countries item=country} {$country.country} {/foreach} |
{$lang.zip_postal_code}: | |
```
Add this new language variable using administration > languages:
[B]Variable:[/B] [I]estimated_shipping[/I] [B]Value:[/B] [I]Estimate shipping[/I]
[B]Variable:[/B] [I]click_estimate_shipping[/I] [B]Value:[/B] [I]Click to estimate shipping[/I]
[B]Variable:[/B] [I]find_rates[/I] [B]Value:[/B] [I]Find rates...[/I]
Modify your file "include/customer/cart_status.php" to look like this:
```php /******************************************************************************
* *
* Copyright (c) 2004-2005 CS-Cart.com. All rights reserved. *
* *
*******************************************************************************
* *
* CS-Cart is commercial software, only users who have purchased a valid *
* license through https://www.cs-cart.com/ and accept to the terms of this *
* License Agreement can install this product. *
* *
*******************************************************************************
* THIS CS-CART SHOP END-USER LICENSE AGREEMENT IS A LEGAL AGREEMENT BETWEEN *
* YOU AND YOUR COMPANY (COLLECTIVELY, "YOU") AND CS-CART.COM (HEREINAFTER *
* REFERRED TO AS "THE AUTHOR") FOR THE SOFTWARE PRODUCT IDENTIFIED ABOVE, *
* WHICH INCLUDES COMPUTER SOFTWARE AND MAY INCLUDE ASSOCIATED MEDIA, PRINTED *
* MATERIALS, AND "ONLINE" OR ELECTRONIC DOCUMENTATION (COLLECTIVELY, THE *
* "SOFTWARE"). BY USING THE SOFTWARE, YOU SIGNIFY YOUR AGREEMENT TO ALL *
* TERMS, CONDITIONS, AND NOTICES CONTAINED OR REFERENCED HEREIN. IF YOU ARE *
* NOT WILLING TO BE BOUND BY THIS AGREEMENT, DO NOT INSTALL OR USE THE *
* SOFTWARE. *
* *
* PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" *
* FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE *
* AT THE FOLLOWING URL: https://www.cs-cart.com/license.html *
******************************************************************************/
//
// $Id: cart_status.php 751 2005-10-13 11:20:41Z zeke $
//
// Minicart mod by Backstrom, inspired by Zardos
if ( !defined('IN_CSCART') ) { die('Access denied'); }
// Include real-time shipping rates calculation functions
@include_once $cscart_dir.DS.'shippings'.DS.'fn_rtsrc.php';
sess_register('cart');
$auth['est_country'] = (empty($auth['est_country'])) ? ((empty($cart['user_data']['s_country'])) ? @$GLOBALS['est_country'] : @$cart['user_data']['s_country']) : @$auth['est_country'];
$auth['est_zipcode'] = (empty($auth['est_zipcode'])) ? ((empty($cart['user_data']['s_zipcode'])) ? @$GLOBALS['est_zipcode'] : @$cart['user_data']['s_zipcode']) : @$auth['est_zipcode'];
$smarty->assign('est_country', @$auth['est_country']);
$smarty->assign('est_zipcode', @$auth['est_zipcode']);
if (!empty($GLOBALS['est_shipping'])) { // compute shipping
$products=0; // use products because cart['amount'] hasn't been coumpted yet
$options=0; // check options because options can chage without products changing.
if (!empty($cart['products'])) {
foreach ($cart['products'] as $k => $v) {
$products+=$v['amount']; // sum number of products
if (!empty($v['product_options'])) {
foreach ($v['product_options'] as $k1 => $v1) {
$options+=$v1; // sum option variant_ids
}
}
}
}
// if item/option added or removed, or country/zip change, recompute shipping
if ( ((@$auth['products']!=$products && $products>0) || (@$auth['options']!=$options && $options>0)) && !empty($auth['est_country'])) {
if ( empty($auth['user_id']) ) {
$auth['area'] = AREA;
$auth['user_id'] = 0;
$auth['membership_id'] = 0;
}
}
extract(fn_calculate_cart_content(&$cart, $auth, true));
$auth['products']=$products;
$auth['options']=$options;
} else {
$cart['est_ship'] = 0;
}
$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['shipping_cost'] = (empty($cart['shipping_cost'])) ? 0 : $cart['shipping_cost'];
$cart['est_ship'] = (empty($cart['est_ship'])) ? 0 : $cart['est_ship'];
$cart['est_total'] = $cart['subtotal'] + $cart['discount'] + $cart['est_ship'];
$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_est_ship', @$cart['est_ship']);
$smarty->assign_by_ref('cart_est_total',@$cart['est_total']);
$smarty->assign_by_ref('est_countries', @fn_get_countries($descr_sl, false, false));
?> ```
Modify the line in file "include/customer/checkout.php" from this:
```php // Include real-time shipping rates calculation functions
@include $cscart_dir.DS.'shippings'.DS.'fn_rtsrc.php'; ```
To this:
```php // Include real-time shipping rates calculation functions
@include_once $cscart_dir.DS.'shippings'.DS.'fn_rtsrc.php'; ```
In file "core/fn_cart.php" locate this:
```php // Apply shipping fee
if ($calculate_shipping == true && $settings['Shippings']['disable_shipping'] != 'Y') {
if (defined('CACHED_SHIPPING_RATES')) {
global $shipping_rates;
} else {
$shipping_rates = fn_calculate_shipping_rates($cart, $cart_products, $auth);
} ```
Change it to this:
```php // Apply shipping fee
if ($calculate_shipping == true && $settings['Shippings']['disable_shipping'] != 'Y') {
if (defined('CACHED_SHIPPING_RATES')) {
global $shipping_rates;
} else {
$shipping_rates = fn_calculate_shipping_rates($cart, $cart_products, $auth);
}
// Minicart get lowest shipping rate, by Backstrom
$est_ship=$shipping_rates;
$sortRate = array();
foreach($est_ship as $rate) $sortRate[] = $rate['rate'];
array_multisort($sortRate, SORT_ASC, $est_ship);
$cart['est_ship']=@$est_ship[0]['rate']; ```
In the same file, locate this:
```php function fn_get_customer_location($auth, $cart, $billing = false)
{
global $settings, $db_tables;
$s_info = array();
$prefix = 's';
if ($billing == true) {
$prefix == 'b';
}
if (empty($cart['user_data'])) {
if (empty($auth['user_id'])) { // Get data for default location
$s_info['country'] = @$settings['General']['default_country'];
$s_info['state'] = @$settings['General']['default_state'];
$s_info['zipcode'] = @$settings['General']['default_zipcode'];
$s_info['city'] = @$settings['General']['default_city'];
$s_info['address'] = @$settings['General']['default_address'];
$s_info['phone'] = '';
$s_info['firstname'] = 'John';
$s_info['lastname'] = 'Doe';
} else { // Get data from user profile
$uinfo = fn_get_user_info($auth['user_id'], $cart['profile_id']);
$s_info['country'] = @$uinfo["{$prefix}_country"];
$s_info['state'] = @$uinfo["{$prefix}_state"];
$s_info['zipcode'] = @$uinfo["{$prefix}_zipcode"];
$s_info['city'] = @$uinfo["{$prefix}_city"];
$s_info['address'] = @$uinfo["{$prefix}_address"];
$s_info['phone'] = @$uinfo["phone"];
if ($prefix == 'b') {
$s_info['firstname'] = (!empty($uinfo['b_firstname'])) ? $uinfo['b_firstname'] : $uinfo['firstname'];
$s_info['lastname'] = (!empty($uinfo['b_lastname'])) ? $uinfo['b_lastname'] : $uinfo['lastname'];
} else {
$s_info['firstname'] = (!empty($uinfo['s_firstname'])) ? $uinfo['s_firstname'] : (!empty($uinfo['b_firstname']) ? $uinfo['b_firstname'] : $uinfo['firstname']);
$s_info['lastname'] = (!empty($uinfo['s_lastname'])) ? $uinfo['s_lastname'] : (!empty($uinfo['b_lastname']) ? $uinfo['b_lastname'] : $uinfo['lastname']);
$s_info['residential_address'] = (!empty($uinfo['residential_address'])) ? $uinfo['residential_address'] : 'Y';
}
}
} else { ```
Change it to this:
```php function fn_get_customer_location($auth, $cart, $billing = false)
{
global $settings, $db_tables;
$s_info = array();
$prefix = 's';
if ($billing == true) {
$prefix == 'b';
}
// MiniCart mod to bypass default, by Backstrom
if (empty($cart['user_data'])) {
if (empty($auth['user_id'])) { // Get data for minicart location
if (!empty($auth['est_country'])) {
$s_info['country'] = @$auth['est_country'];
$s_info['state'] = '';
$s_info['zipcode'] = @$auth['est_zipcode'];
$s_info['city'] = '';
$s_info['address'] = '';
$s_info['phone'] = '';
$s_info['firstname'] = 'John';
$s_info['lastname'] = 'Doe';
} else { // Get data for default location
$s_info['country'] = @$settings['General']['default_country'];
$s_info['state'] = @$settings['General']['default_state'];
$s_info['zipcode'] = @$settings['General']['default_zipcode'];
$s_info['city'] = @$settings['General']['default_city'];
$s_info['address'] = @$settings['General']['default_address'];
$s_info['phone'] = '';
$s_info['firstname'] = 'John';
$s_info['lastname'] = 'Doe';
}
} else { // Get data from user profile
$uinfo = fn_get_user_info($auth['user_id'], $cart['profile_id']);
$s_info['country'] = @$uinfo["{$prefix}_country"];
$s_info['state'] = @$uinfo["{$prefix}_state"];
$s_info['zipcode'] = @$uinfo["{$prefix}_zipcode"];
$s_info['city'] = @$uinfo["{$prefix}_city"];
$s_info['address'] = @$uinfo["{$prefix}_address"];
$s_info['phone'] = @$uinfo["phone"];
if ($prefix == 'b') {
$s_info['firstname'] = (!empty($uinfo['b_firstname'])) ? $uinfo['b_firstname'] : $uinfo['firstname'];
$s_info['lastname'] = (!empty($uinfo['b_lastname'])) ? $uinfo['b_lastname'] : $uinfo['lastname'];
} else {
$s_info['firstname'] = (!empty($uinfo['s_firstname'])) ? $uinfo['s_firstname'] : (!empty($uinfo['b_firstname']) ? $uinfo['b_firstname'] : $uinfo['firstname']);
$s_info['lastname'] = (!empty($uinfo['s_lastname'])) ? $uinfo['s_lastname'] : (!empty($uinfo['b_lastname']) ? $uinfo['b_lastname'] : $uinfo['lastname']);
$s_info['residential_address'] = (!empty($uinfo['residential_address'])) ? $uinfo['residential_address'] : 'Y';
}
}
} else { ```
This mod has been testing with Realtime shipping for USPS,FEDEX,UPS. Let me know if we need to tweak the code. Enjoy