Re: Shoppingcart/Freeship in Header support
This mod is a perfect additon to zen and I have used it on 1.5.0. I ship nationally and overseas. I also have the shipping estimator option showing within the cart (not as a separate pop-up). Therefore, users see shipping when in the cart and can choose their location.
Is there a way to modify the code so that the 'add $$ to cart to qualify for free shipping etc' only appears when the national (and default location) is picked in the estimator and is removed when a customer picks another (overseas/international) location?
Might be a tall order. I notice, however, that the module must link to Orders Total Modules > Shipping since it is in here that the relevant value for Free Shipping is set. That page also has a value for where free shipping is applicable: national, international, both - so there may be scope?
Any ideas?
Re: Shoppingcart/Freeship in Header support
The mod doesn't need to link into any shipping modules; it just uses values/constants set by them. It would probably be possible to use or look up the customer's country if it is set... I don't know about the estimator, whether the setting there is accessible. If it is set by javascript, it would likely not be accessible to the PHP code that operates the header mod.
Re: Shoppingcart/Freeship in Header support
Glenn (or any Zen Cart guru),
I am trying to modify the "Shoppingcart/Freeship" in Header to include product name (productsName) and product image (productsImage). I have installed it in a dropdown menu. It looks good and functions nicely.
I have tried to modify the php in "Shoppingcart/Freeship in Header" to display the product name and product image but cannot seem to do it. I am not very familiar with php. I am able to position things with divs and css. I am able to pull code out of the shopping cart page but when I install it in the plugin it only works in the dropdown menu on the shopping cart page. I would like it to display $0.00 and 0 Items like it does when the cart is empty. I
Here is an example http://www.graphiclabtees.com/. I believe that this is a wp site, however if you add something to the cart, you can see how it displays in the dropdown.
Any help or information would be appreciated. I like the plugin, I would just like to display a little more information.
Thanks you in advance.
Re: Shoppingcart/Freeship in Header support
The reason your transplanted code works on the shopping cart page and not elsewhere is probably that it uses database lookups generated for that page, and not for other pages. You would need to do a database lookup for the information you want, in the mod files so it will always be available. Check /includes/modules/pages/shopping_cart/main_template_vars.php, which is likely to be the place where this db lookup is performed for the cart page. This should serve as an example for the SQL you need.
Re: Shoppingcart/Freeship in Header support
Glenn,
Thanks for the information. I checked for /includes/modules/pages/shopping_cart/main_template_vars.php. There was no main_template_vars.php in that folder. I did find a main_template_vars.php file in the /includes/modules/pages/product info folder. I looked at the code but couldn't figure it out.
Is there some code that can be inserted into your plugin that would display the product name and product image. I am not sure what is needed to call this information. Is this some major php coding? I have been looking into this for a few days now without any luck. I'm sure the information you gave me points me in the right direction, but not being familiar with php, I really have no idea how to get this done. It may be harder than I think.
Can you give me a brief explanation of what needs to be done? I am going to pose the question and code below, if another Zen Cart Guru comes across this post and is able to help.
To see the plugin on my site, visit www.4twentee.com. The dropdown menu is in the main nav under Shopping Cart.
Thanks Again,
Jesse
How can I display product name (productsName) and product image (productsImage) in "Shoppingcart/Freeship in Header" plugin?
<?php
/**
* tpl_cart_header.php
* @copyright Copyright 2012 Glenn Herbert
* @copyright Portions Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.gnu.org/licenses/ GNU Public License V3.0
* /includes/templates/your_template/templates/tpl_cart_header.php
* Shoppingcart/Freeship in Header - Glenn Herbert (gjh42) - 2012-11-20
*/
$cart_count = $_SESSION['cart']->count_contents();
?>
<div id="cartHeader">
<?php echo ($cart_count? '<a href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '">' . CART_HEADER_TITLE . '</a>':CART_HEADER_TITLE); ?>
<div id="cartCount">
<?php
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><br />
' ;
}
echo ($cart_count? '':'') . CART_HEADER_IN_CART_PRE . $cart_count . (($cart_count == 1)? CART_HEADER_IN_CART_SINGULAR: CART_HEADER_IN_CART_PLURAL) . ($cart_count? '': '');
?>
</div>
<?php
if ($cart_count) {
echo '<div class="buttonRow back"><a href="' . zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL') . '">' . zen_image_button(BUTTON_IMAGE_VIEW_CART, BUTTON_VIEW_CART_ALT) . '</a></div>';
echo '<div class="buttonRow forward"><a href="' . zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . zen_image_button(BUTTON_IMAGE_CHECKOUT, BUTTON_CHECKOUT_ALT) . '</a></div>';
} ?>
</div>
Re: Shoppingcart/Freeship in Header support
For the shopping cart page, the basic info is retrieved and massaged in /includes/modules/pages/shopping_cart/header_php.php.
PHP Code:
$products = $_SESSION['cart']->get_products();
This method is available anywhere as it is part of the $_SESSION superglobal.
Later in that file we have
PHP Code:
$productsImage = (IMAGE_SHOPPING_CART_STATUS == 1 ? zen_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], IMAGE_SHOPPING_CART_WIDTH, IMAGE_SHOPPING_CART_HEIGHT) : '');
which shows that the image and name are accessible as $products[$i]['image'] and $products[$i]['name']. You need to loop through $products incrementing $i (or whatever variable) and pulling the name and image for each, and putting them in a custom array or outputting them, or whatever you want to do.
Re: Shoppingcart/Freeship in Header support
You would want to use a different variable name than $products so as not to conflict with the existing instance of it, maybe $cart_header_products.
Re: Shoppingcart/Freeship in Header support
Glenn,
I appreciate your feedback. I am going to give this a shot. I took this code from the shopping cart and modified it. I changed $products to $cart_header_products. Do I have to define this somewhere?
I added this to my code. It shows in the shopping cart page but nowhere else.
<table border="0" width="100%" cellspacing="0" cellpadding="0" id="cartHeaderDisplay">
<?php
foreach ($productArray as $cart_header_products) {
?>
<tr class="<?php echo $cart_header_['rowClass']; ?>">
<td class="cartProductDisplay">
<a href="<?php echo $cart_header_products['linkProductsName']; ?>"><span id="cartImage" class="back"><?php echo $cart_header_products['productsImage']; ?></span><span id="cartProdTitle"><?php echo $cart_header_products['productsName'] . '<span class="alert bold">' . $cart_header_products['flagStockCheck'] . '</span>'; ?></span></a>
</td>
</tr>
<?php
} // end foreach ($productArray as $cart_header_products)
?>
<!-- Finished loop through all products /-->
</table>
Re: Shoppingcart/Freeship in Header support
Just using $productArray makes you dependent on the shopping cart page code. You need to get it directly from $_SESSION:
PHP Code:
$cart_header_products = $_SESSION['cart']->get_products();
Then you can iterate through $cart_header_products, putting the name and image of each item in your output.
Re: Shoppingcart/Freeship in Header support
Glenn,
This is what I came up with. I am not sure how to add the array. I tried to use the code from your plugin as an example, but this is not working. Am I on the right track? The code after echo is from the shopping cart page using $cart_header_products.
<?php
if ($cart_count) {
$cart_header_products = $_SESSION['cart']->get_products();
echo <a href="<?php echo $cart_header_products['linkProductsName']; ?>"><span id="cartImage" class="back"><?php echo $cart_header_products['productsImage']; ?></span><span id="cartProdTitle"><?php echo $cart_header_products['productsName'] . '<span class="alert bold">' . $cart_header_products['flagStockCheck'] . '</span>'; ?></span></a>;
}
?>