Zen Cart Logo
Forums / All Other Contributions/Addons / Shoppingcart/Freeship in Header support

Shoppingcart/Freeship in Header support

Views: 19,391

Results 1 to 20 of 181
04 Oct 2009, 19:26
#1
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Shoppingcart/Freeship in Header support

Shoppingcart/Freeship in Header has been submitted to Free Addons and should be available soon.

This mod will give you a box in your header which shows the number of items in the cart, the total amount if any items in cart, the amount required to qualify for free shipping, and a checkout button if any items in cart.

You can set its position and style by editing your stylesheet with rules suggested in the readme.

Compatible with multiple languages.

27 Nov 2009, 16:28
#2
autoace avatar

autoace

Totally Zenned

Join Date:
Jun 2009
Posts:
618
Plugin Contributions:
0

Re: Shoppingcart/Freeship in Header support

Very cool mod! Great, absolutely great readme file with clear and precise instructions and info - and here is the bonus, its not a text file!

The only thing that I would like to customize about it is, I would like to format it into 2 columns. The first column being the # of items on the first row and the second row, the Total Price. On the second column on the first row is where I want to place the View Cart button.

Can I do that via css? How? I'm a bit of a novice when it comes to css, so if someone can provide some example code, awesome!

30 Nov 2009, 16:06
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Shoppingcart/Freeship in Header support

Rearranging the box layout into columns as you describe, and adding a separate View Cart button that is always on instead of a link on the count when full, is beyond the capacities of CSS and will require a bit of restructuring of code.

Find this section in tpl_cart_header.php```php

<div id="cartCount"> <?php $cart_count = $_SESSION['cart']->count_contents(); if ($cart_count) { $_SESSION['cart']->get_products(); $basket_total = $_SESSION['cart']->show_total(); echo '<span id="cartTotal">' . CART_HEADER_TOTAL . $currencies->format($basket_total) . '</span>' ; } echo ($cart_count? '<a href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '" title="' . CART_HEADER_TITLE . '">':'') . CART_HEADER_IN_CART_PRE . $cart_count . (($cart_count == 1)? CART_HEADER_IN_CART_SINGULAR: CART_HEADER_IN_CART_PLURAL) . ($cart_count? '</a>': ''); ?> </div> ``` Add

echo '<a id="cartButton" href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '" title="' . CART_HEADER_TITLE . '"><img src="yourimagesource.gif" /></a>': '');

to get```php

<div id="cartCount"> <?php $cart_count = $_SESSION['cart']->count_contents(); if ($cart_count) { $_SESSION['cart']->get_products(); $basket_total = $_SESSION['cart']->show_total(); echo '<span id="cartTotal">' . CART_HEADER_TOTAL . $currencies->format($basket_total) . '</span>' ; } echo ($cart_count? '<a href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '" title="' . CART_HEADER_TITLE . '">':'') . CART_HEADER_IN_CART_PRE . $cart_count . (($cart_count == 1)? CART_HEADER_IN_CART_SINGULAR: CART_HEADER_IN_CART_PLURAL) . ($cart_count? '</a>': ''); ?> </div> <?php echo '<a id="cartButton" href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '" title="' . CART_HEADER_TITLE . '"><img src="yourimagesource.gif" /></a>': ''); ?> ```You would also want more <span> elements to control the qty and total.

Then style as required:```
/Shoppingcart/Freeship in Header/
#headerWrapper {position: relative;}

#cartHeader {
width: 30em;/17em/
position: absolute;
top: 0.1em;/4.0em/
right: 2.0em;
/*bottom:0.1em;/added/
background: #cacaca;
color: #000000;
border: 1px solid #888888;
}

#cartHeader h3 {
display: none;/added/
/text-align: center;/
/*color: #005599;/added/
/*margin:0.1em 0;/added/
}
#cartCount {
/border-top: 1px solid #999999;/
text-align: left;/center/
padding: 0.5em 0;/added/
float: left;
}
#cartCount a {)
#cartTotal {}
#cartFreeShip {
margin: 0 0.3em;
}
#cartCheckout {
float: left;/right/
margin: 0.3em;
}

#cartButton {
display: block;
float: right;
width: 123px; /adjust to fit/
}

30 Nov 2009, 16:15
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Shoppingcart/Freeship in Header support

<div id="cartCount">
<?php
$cart_count = $_SESSION['cart']->count_contents();

echo ($cart_count? '<a href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '" title="' . CART_HEADER_TITLE . '">':'') . CART_HEADER_IN_CART_PRE . $cart_count . (($cart_count == 1)? CART_HEADER_IN_CART_SINGULAR: CART_HEADER_IN_CART_PLURAL) . ($cart_count? '</a>': '');
?>
</div>
if ($cart_count) { 
  $_SESSION['cart']->get_products(); 
  $basket_total = $_SESSION['cart']->show_total();
  echo '<div id="cartTotal">' . CART_HEADER_TOTAL . $currencies->format($basket_total) . '</div>' ; 
}
<?php echo '<a id="cartButton" href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '" title="' . CART_HEADER_TITLE . '"><img src="yourimagesource.gif" /></a>': ''); ?>
#cartTotal {
    float: left;
    }
30 Nov 2009, 17:27
#5
autoace avatar

autoace

Totally Zenned

Join Date:
Jun 2009
Posts:
618
Plugin Contributions:
0

Re: Shoppingcart/Freeship in Header support

Thanks for the reply.

I copied that line of code and put it at the bottom of my tpl_cart_header page and then refreshed FF and the page came up blank, all it shows is my header background color and my logo image at the left corner. Everything under the header area is gone.

It seems in your post that extra line of code is to be placed at the bottom of the file, correct?

The reason why I know its this particular line of code causing the problem is that my site was fine before, any help is greatly appreciated!

30 Nov 2009, 18:09
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Shoppingcart/Freeship in Header support

Oops - forgot to wrap php tags around the relocated code. Since its new location is outside the original php section, it needs those for itself.```php

<div id="cartCount"> <?php $cart_count = $_SESSION['cart']->count_contents();

echo ($cart_count? '<a href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '" title="' . CART_HEADER_TITLE . '">':'') . CART_HEADER_IN_CART_PRE . $cart_count . (($cart_count == 1)? CART_HEADER_IN_CART_SINGULAR: CART_HEADER_IN_CART_PLURAL) . ($cart_count? '</a>': '');
?>

</div> <?php if ($cart_count) { $_SESSION['cart']->get_products(); $basket_total = $_SESSION['cart']->show_total(); echo '<div id="cartTotal">' . CART_HEADER_TOTAL . $currencies->format($basket_total) . '</div>' ; } ?> <?php echo '<a id="cartButton" href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '" title="' . CART_HEADER_TITLE . '"><img src="yourimagesource.gif" /></a>': ''); ?> ``` I have attached the zip file here until the mod is activated in Free Addons.
30 Nov 2009, 23:28
#7
damiendlskinsolution avatar

damiendlskinsolution

Zen Follower

Join Date:
Sep 2008
Posts:
97
Plugin Contributions:
0

Re: Shoppingcart/Freeship in Header support

Glenn,

I love the idea. I tried your last piece of code but no luck... "500 - Internal server error" is was i get.
The original code works, it's the mod above that crashes the page.
Not sure why, my php skills are still close to none. :blush:

It's that part that cause the error:

<?php echo '<a id="cartButton" href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '" title="' . CART_HEADER_TITLE . '"><img src="whatever.png" /></a>': ''); ?>

Any idea on what's missing?

Thanks for your help and support on Zen Cart. Love your "Smart Background" add-on btw.

01 Dec 2009, 03:12
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Shoppingcart/Freeship in Header support

Ack! I was typing in a hurry and missed the last bit that needed to be removed:
: ''
at the end of the statement. This will work:```php

<?php echo '<a id="cartButton" href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '" title="' . CART_HEADER_TITLE . '"><img src="whatever.png" /></a>'); ?>
08 Jan 2010, 08:13
#10
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Shoppingcart/Freeship in Header support

"I have also the slovenian language, wich don't have only singular and plural.

Should be like that:

1 item in card- Izdelek
2 items in card- Izdelka
3 items in card- Izdelki
4 items in card- Izdelki
5 items in card- Izdelkov
6 items in card- Izdelkov
7 items in card- Izdelkov.......( and so on, the same)"

What would be the word for zero or no items in cart?

Edit /includes/templates/your_template/templates/tpl_cart_header.php.

echo ($cart_count? '<a href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '" title="' . CART_HEADER_TITLE . '">':'') . CART_HEADER_IN_CART_PRE . $cart_count . (($cart_count == 1)? CART_HEADER_IN_CART_SINGULAR: CART_HEADER_IN_CART_PLURAL) . ($cart_count? '</a>': '');

Replace
(($cart_count == 1)? CART_HEADER_IN_CART_SINGULAR: CART_HEADER_IN_CART_PLURAL)
with
$cart_header_number

echo ($cart_count? '<a href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '" title="' . CART_HEADER_TITLE . '">':'') . CART_HEADER_IN_CART_PRE . $cart_count . $cart_header_number . ($cart_count? '</a>': '');

Add just above that```php
switch ($cart_count){
case '0':
$cart_header_number = CART_HEADER_IN_CART_QTY_0;
break;
case '1':
$cart_header_number = CART_HEADER_IN_CART_QTY_1;
break;
case '2':
$cart_header_number = CART_HEADER_IN_CART_QTY_2;
break;
case '3':
$cart_header_number = CART_HEADER_IN_CART_QTY_3_4;
break;
case '4':
$cart_header_number = CART_HEADER_IN_CART_QTY_3_4;
break;
default:
$cart_header_number = CART_HEADER_IN_CART_QTY_5;
break;
}

Then in cart_header_defines.php, add these lines:```php
define{'CART_HEADER_IN_CART_QTY_0','Izdelek');//???word to use here???
define{'CART_HEADER_IN_CART_QTY_1','Izdelek');
define{'CART_HEADER_IN_CART_QTY_2','Izdelka');
define{'CART_HEADER_IN_CART_QTY_3_4','Izdelki');
define{'CART_HEADER_IN_CART_QTY_5','Izdelkov');
08 Jan 2010, 16:48
#11
jeet_kune_do avatar

jeet_kune_do

Zen Follower

Join Date:
Nov 2008
Location:
Slovenija
Posts:
119
Plugin Contributions:
0

Re: Shoppingcart/Freeship in Header support

The words is "Izdelkov".

I don't have words to thank you!

Please provide me your paypal account, so I can make you a donation. :wink:

03 Feb 2010, 17:53
#12
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Shoppingcart/Freeship in Header support

A tweak that may be useful is to add a link from the "Free shipping for orders of $xx or more" to the shipping & returns page, where customers can easily get the complete details.
In cart_header_defines.php, change this php define ('CART_HEADER_FREE_LIMIT_PRE','Free Shipping for orders of<br />'); to this```php
define ('CART_HEADER_FREE_LIMIT_PRE','<a href="index.php?main_page=shippinginfo">Free Shipping</a> for orders of<br />');

06 Feb 2010, 05:36
#13
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Shoppingcart/Freeship in Header support

A quirk of the free shipping setup which is not explained in the readme is that there appear to be two places where this setting can be made.

Modules > Shipping > Free Shipping Options (freeoptions) actually causes the shipping to be free if over the set dollar amount.
The constant that free shipping alert mods use, MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER, is set in Modules > Order Total > Shipping (ot_shipping), and is not affected by the functional freeoptions setting.

So if you want both the shipping and the alert to work together, you need to make the same setting in both places.

08 Feb 2010, 21:52
#14
royal avatar

royal

Zen Follower

Join Date:
Jun 2008
Location:
Canada
Posts:
261
Plugin Contributions:
0

Re: Shoppingcart/Freeship in Header support

Hello Glen,

On my website any order over $10 get 10% off. It does not show the discounted total. Is it possible to show discount in the total?

08 Feb 2010, 21:57
#15
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Shoppingcart/Freeship in Header support

Discounts are generally applied at checkout, so I don't think there is an easy way to get the discounted total to show in the header. You could write some custom code to do the test and calculation on the cart total.

08 Feb 2010, 23:53
#16
royal avatar

royal

Zen Follower

Join Date:
Jun 2008
Location:
Canada
Posts:
261
Plugin Contributions:
0

Re: Shoppingcart/Freeship in Header support

Thank you, Glen!

16 Feb 2010, 07:04
#17
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Shoppingcart/Freeship in Header support

Shoppingcart/Freeship in Header is now available in Free Addons.

21 Feb 2010, 06:35
#18
djoel avatar

djoel

New Zenner

Join Date:
Aug 2009
Posts:
56
Plugin Contributions:
0

Re: Shoppingcart/Freeship in Header support

Hello,

Did I miss something or why everything is showing up as text?

look here

And secondly, when I add the proposed definitions to my stylesheets my sidebox changes completely.

Any help would be much appreciated.

22 Feb 2010, 03:32
#19
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Shoppingcart/Freeship in Header support

The text you are seing is because those constants are not being defined. Did you add cart_header_defines.php to the correct folder, setting the folder name to your custom template?

When you say "added definitions to your stylesheet", do you mean the constant definitions mentioned above, or the style rules in the readme?
/Shoppingcart/Freeship in Header/
#headerWrapper {position: relative;}

#cartHeader {...

Those rules should not affect anything except the cart-header, except that the

#headerWrapper {position: relative;}

could affect any elements that are inside the header code and absolutely positioned (there won't be any such unless you have specifically made them so).
You might try commenting out this one rule; if that helps, you can rework the positioning properties as requred.

22 Feb 2010, 04:37
#20
djoel avatar

djoel

New Zenner

Join Date:
Aug 2009
Posts:
56
Plugin Contributions:
0

Re: Shoppingcart/Freeship in Header support

Oops... you're right. I tested it on my french site and the cart_header_defines.php slipped into my english folder.

The sidebox is also displying fine now. Maybe a drag and drop issue by myself.

Next time I will check thoroughly before posting.

Thank you for advice!