Deceased
- Join Date:
- Jan 2007
- Location:
- Australia
- Posts:
- 6,263
- Plugin Contributions:
- 4
Views: 4,078
Deceased
Deceased
For those still playing..
<h3 id="cartEmptyText"><?php echo TEXT_CART_EMPTY; ?></h3>
<?php
$show_display_shopping_cart_empty = $db->Execute(SQL_SHOW_SHOPPING_CART_EMPTY);
while (!$show_display_shopping_cart_empty->EOF) {
?>
<?php
if ($show_display_shopping_cart_empty->fields['configuration_key'] == 'SHOW_SHOPPING_CART_EMPTY_FEATURED_PRODUCTS') { ?>
<?php
/**
* display the Featured Products Center Box
*/
?>
<?php require($template->get_template_dir('tpl_modules_featured_products.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products.php'); ?>
<?php } ?>
<?php
if ($show_display_shopping_cart_empty->fields['configuration_key'] == 'SHOW_SHOPPING_CART_EMPTY_SPECIALS_PRODUCTS') { ?>
<?php
/**
* display the Special Products Center Box
*/
?>
<?php require($template->get_template_dir('tpl_modules_specials_default.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_specials_default.php'); ?>
<?php } ?>
<?php
if ($show_display_shopping_cart_empty->fields['configuration_key'] == 'SHOW_SHOPPING_CART_EMPTY_NEW_PRODUCTS') { ?>
<?php
//display the New Products Center Box
require($template->get_template_dir('tpl_modules_whats_new.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_whats_new.php');
if ($num_products_count === 0) {
/////////////////////// Show Categories Box. ////////////////////////////////////
$main_category_tree = new category_tree;
$row = 0;
$box_categories_array = array();
// don't build a tree when no categories
$check_categories = $db->Execute("select categories_id from " . TABLE_CATEGORIES . " where categories_status=1 limit 1");
if ($check_categories->RecordCount() > 0) {
$box_categories_array = $main_category_tree->zen_category_tree();
}
require($template->get_template_dir('tpl_categories.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_categories.php');
$title = BOX_HEADING_CATEGORIES;
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
//////////////////////////////////////////////////////////////////
}
} ?>
<?php
if ($show_display_shopping_cart_empty->fields['configuration_key'] == 'SHOW_SHOPPING_CART_EMPTY_UPCOMING') {
include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS));
}
?>
<?php
$show_display_shopping_cart_empty->MoveNext();
} // !EOF
This code is incomplete. it is to show what I've added to get the categories list
Still no luck with any attempts to use a redirect. :(
Chhers
RodG
Deceased
mc12345678:
What's happening downstream? Ie, regarding the particular category to which the guest is being sent? Is there yet another redirect somewhere there? Can you enter in the browser the path to the category without getting the error?
No other redirects going on. No SEO modules enabled (as if there could be much doubt).
Even attempting to redirect to the front page (store/index.php gives the headers already sent error)
Cheers
RodG
Deceased
Before I hit the pillow:
DrByte tackled something similar 3 years ago: http://www.zen-cart.com/showthread.php?188948-can-I-redirect-customers-to-category-page-after-login&p=1082025#post1082025
Worth a look see...
Nighty Night
NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.
Totally Zenned
RodG:
No other redirects going on. No SEO modules enabled (as if there could be much doubt).
Even attempting to redirect to the front page (store/index.php gives the headers already sent error)
Cheers
RodG
So, almost have to say, should go back to check the current. cart to a default new install. At lest the applicable header files. Both frank and I have been able to successfully add our unique versions of redirect without an error.
I do seem to recall (and maybe it was in ZC1.5.0) having to add some sort of header clearing instruction into one of the header files. I don't remember if it was the common header or one of the page headers. For others looking, the reason I suggest the comparison to a clean install is that the includes/modules/pages does not offer an override possibility, so any changes to the headers in that directory would only be possible to identify by comparison to a fresh install.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Deceased
frank18:
Before I hit the pillow:
DrByte tackled something similar 3 years ago: http://www.zen-cart.com/showthread.php?188948-can-I-redirect-customers-to-category-page-after-login&p=1082025#post1082025
Worth a look see...
Nighty Night
I've already seen that post, but wasn't able to find the secret incantations to adapt it to suit my needs. This is one of those areas where I'm going to need a little more handholding. :)
Thanks for your efforts though.
What has me puzzled now is how you managed to get the redirect in the tpl_shipping_cart_default.php to work, but mine aborts the processing due the the headers already being sent, so that is what I'm going to be investigating a little further before calling it a night.
Cheers
RodG
Deceased
mc12345678:
I do seem to recall (and maybe it was in ZC1.5.0) having to add some sort of header clearing instruction into one of the header files. I don't remember if it was the common header or one of the page headers.
I should have mentioned long ago, the site under development is V1.5.2-Beta (RC2)
Cheers
RodG
Totally Zenned
RodG:
I should have mentioned long ago, the site under development is V1.5.2-Beta (RC2)
Cheers
RodG
Ahh, now I see said the blind man.
Okay, so two things come to mind, in review of what causes the error identified, it seems that if output_buffering (in php.ini) is disabled, then it is possible that header code could have already been sent by the time the redirect is mmet. This supposedly can also happen if there is space between php close and open statements. Or at the end of a file. Or possibly the template used has an issue that is sending the header prematurely. So thts some of the code area.
The other thing to do is to go ahead and compare 1.5.1 to this new beta/RC2 and see if there is something missing/added that could/would cause this issue. But, thing is that redirects re used on other pages (at least one template file had a zen_redirect command relating to unsubscribing. Is it possible to "activate" that template file and see if the same error appears? If so, then it's probably in a common header file, if not then more likely in the shopping cart "path".
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Oba-san
You could just add to the file:
/includes/templates/your_templates_dir/tpl_shopping_cart_default.php
the code in RED around line 184:
<?php
$show_display_shopping_cart_empty = $db->Execute(SQL_SHOW_SHOPPING_CART_EMPTY);
[B]// bof: force category 3 on empty cart
$new_products_category_id = 3;
$cPath = '3';
// eof: force category on empty cart
[/B]
while (!$show_display_shopping_cart_empty->EOF) {
?>
where 3 is the categories_id that you wish to use ...
Linda McGrath
If you have to think ... you haven't been zenned ...
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
Totally Zenned
Uhm... I've missed a major part of this conversation (that's what happens when you sleep for 20 hours :smile:), but...
I'd like to advise AGAINST any redirects from the empty cart page. The zen_redirect was actually the first thing I thought off, but immediately crossed it out because of UX and confusion it might cause. Think about it from a customers' perspective - click the "shopping cart" link, a category shows up. Huh? Click shopping cart link again, category shows up again. There must be something broken here.... Don't forget that this can easily happen when session expires (customers don't care about sessions, add products to cart, take their dog for a walk and are aggravated when they come back 45 minutes later only to find their cart isn't waiting for them...). The ONLY way I would use zen_redirect would be by adding a notice in messageStack, but that's not really a user-friendly solution.
IMHO, the best solution would be keeping the cart page, together with the TEXT_CART_EMPTY, followed by some text like "may we interest you in...". Now, this can be done as a centerbox module like I made it (which is just a starting point, would need a bit more work) OR even better, create a new module that would have the product_listing layout and would look exactly as if a customer was redirected to some category, but keeping the TEXT_CART_EMPTY on top.
Just my 2c...
My site - Pro ZC Help
My portfolio | My plugins
Oba-san
What I posted in post #29 uses no redirects ... that is all the code I added to make category 3 show on the empty cart ...
Linda McGrath
If you have to think ... you haven't been zenned ...
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
Deceased
<?php $show_display_shopping_cart_empty = $db->Execute(SQL_SHOW_SHOPPING_CART_EMPTY); [B]// bof: force category 3 on empty cart $new_products_category_id = 3; $cPath = '3'; // eof: force category on empty cart [/B] while (!$show_display_shopping_cart_empty->EOF) { ?>Ajeh:
You could just add to the file:
/includes/templates/your_templates_dir/tpl_shopping_cart_default.phpthe code in RED around line 184:
>
> where 3 is the categories_id that you wish to use ...
Oooh. I see what you've done there. <smiles>
It's not quite what I was after, as in it doesn't show the products from the specified category (perhaps I've done something wrong. It's 2:35am and I was just about to call it a night when this came in).
What it *does* do however is expand and and highlight the desired category from the categories list that I currently have displaying as per the screenshot I posted earlier, and that alone is going to keep the client a little happier.
BTW, the code additions I've already made in post#22 was something I found in one of the forums, written by you (can't remember what it was in relation too) but I thank you for writing and posting it. :-)
Now if only I could get the *products* from the category to show instead......
Cheers
RodG
(G'night)
Oba-san
I get Products in all the center boxes ... don't you?
What are you using for:
$new_products_category_id
$cPath
Have you a link to your site that we could perhaps peek at this?
Linda McGrath
If you have to think ... you haven't been zenned ...
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
Deceased
Ajeh:
I get Products in all the center boxes ... don't you?
What are you using for:
$new_products_category_id
$cPathHave you a link to your site that we could perhaps peek at this?
Works for me - products and all (zc 1.5.1), so me thinks RodG has some sort of a bug in his 1.5.2 BETA.
NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.
Totally Zenned
balihr:
Uhm... I've missed a major part of this conversation (that's what happens when you sleep for 20 hours :smile:), but...
I'd like to advise AGAINST any redirects from the empty cart page. The zen_redirect was actually the first thing I thought off, but immediately crossed it out because of UX and confusion it might cause. Think about it from a customers' perspective - click the "shopping cart" link, a category shows up. Huh? Click shopping cart link again, category shows up again. There must be something broken here.... Don't forget that this can easily happen when session expires (customers don't care about sessions, add products to cart, take their dog for a walk and are aggravated when they come back 45 minutes later only to find their cart isn't waiting for them...). The ONLY way I would use zen_redirect would be by adding a notice in messageStack, but that's not really a user-friendly solution.
IMHO, the best solution would be keeping the cart page, together with the TEXT_CART_EMPTY, followed by some text like "may we interest you in...". Now, this can be done as a centerbox module like I made it (which is just a starting point, would need a bit more work) OR even better, create a new module that would have the product_listing layout and would look exactly as if a customer was redirected to some category, but keeping the TEXT_CART_EMPTY on top.
Just my 2c...
No argument from me. Like many with a "good problem" I got too fixated on getting the redirect to work after finding out it didn't. I had asked about two potential solutions for the end user, the redirect seemed the easiest (until ajeh came along... :) ) and I had hoped that the "special" category would handle such a comment situation, but that may have been one assumption too deep. Thanks for setting us (or at least me) straight balihr! :)
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Deceased
Ajeh:
I get Products in all the center boxes ... don't you?
Sadly, no it didn't, but armed with the knowledge that it should be working, I've followed the code to see what was going on and have managed to get it working as the client requires <Hoorah>
This solution is exactly what I needed. I can't thank you enough.
So, I guess now you are wondering why it wasn't working last night? Me too. <grin>
Seriously though, to get it to work I needed to make one small edit in the 'new_products.php' file (which I'll need to investigate further),
The edit being to change the
$display_limit = zen_get_new_date_range();
to
$display_limit = '' ;
Without this change it gives an SQL syntax error.
As a temporary measure I've added a conditional clause so that it only nullifies the $display_limit for this particular category. I hope no one will notice <LOL>
Thanks again to all that have offered help and suggestions. THIS is one of the things that make ZenCart leagues ahead of all others.
Cheers
RodG
Deceased
balihr:
I'd like to advise AGAINST any redirects from the empty cart page. The zen_redirect was actually the first thing I thought off, but immediately crossed it out because of UX and confusion it might cause. Think about it from a customers' perspective - *click the "shopping cart" link, a category shows up. Huh? Click shopping cart link again, category shows up again. *
FWIW, I had also considered the confusion that would occur using this method, but I had a little trick up my sleeve. I was planning to save a session variable if the cart was empty, and then use this to output a 'Your cart is empty' on the redirected page. :)
I like the current solution so much better. It is exactly what I was hoping for, but I wasn't familiar with the code/modules to implement it.
Cheers
RodG
Totally Zenned
RodG:
FWIW, I had also considered the confusion that would occur using this method, but I had a little trick up my sleeve. I was planning to save a session variable if the cart was empty, and then use this to output a 'Your cart is empty' on the redirected page. :)
Glad to hear Ajeh's solution works for you - I didn't realize you were OK with using the existing centerboxes and was under the impression you wanted a product_listing layout...
As for the redirect, although it's a nasty solution, someone else might want it so...
includes/modules/pages/shopping_cart/header_php.php, right after
$zco_notifier->notify('NOTIFY_HEADER_START_SHOPPING_CART');
add:
if($_SESSION['cart']->count_contents() < 1) {
$messageStack->add_session('header', 'your cart is empty', 'caution');
zen_redirect(zen_href_link(FILENAME_DEFAULT, zen_get_path(23)));
}
Text in red is, of course, up to you...
My site - Pro ZC Help
My portfolio | My plugins
Totally Zenned
balihr:
Glad to hear Ajeh's solution works for you - I didn't realize you were OK with using the existing centerboxes and was under the impression you wanted a product_listing layout...
As for the redirect, although it's a nasty solution, someone else might want it so...
includes/modules/pages/shopping_cart/header_php.php, right after
$zco_notifier->notify('NOTIFY_HEADER_START_SHOPPING_CART');
> add:
> ```
if($_SESSION['cart']->count_contents() < 1) {
$messageStack->add_session('header', 'your cart is empty', 'caution');
zen_redirect(zen_href_link(FILENAME_DEFAULT, zen_get_path(23)));
}
Text in red is, of course, up to you...
Although I don't have the code together like balihr did above, taking it "to the next level" would be to use an observer on that notifier. Seems like an ideal location, possibility. No changes to the existing code necessary. :)
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Oba-san
RodG:
The edit being to change the
$display_limit = zen_get_new_date_range();
to
$display_limit = '' ;
The function zen_get_new_date_range() obtains the date range based on your settings in the Maximum Values for what you consider to be New Products ...
New Product Listing - Limited to ...
Limit the New Product Listing to
0= All Products
1= Current Month
7= 7 Days
14= 14 Days
30= 30 Days
60= 60 Days
90= 90 Days
120= 120 Days
Without that, all Products are grabbed and the limit on the display attempts to grab all products regardless of when the Products were added ...
Linda McGrath
If you have to think ... you haven't been zenned ...
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
Tell staff why this post should be reviewed.