Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Aug 2008
    Posts
    9
    Plugin Contributions
    0

    Default Assorted Wine Crates

    (Forgive me if there's already a thread for this contribution -- I couldn't find it with a search)

    I've recently had the need to limit shipping to boxes of 6 or 12 items. Fortunately there's a contrib by georgfly for exactly this purpose. However, I did find a bug and thought I'd post a solution here for anyone else needing it. I'm currently testing it on ZC 1.5.0 -- looking good so far.

    At the end of the classes/observers/class.weinkartons_amount.php file, in the case statement there is the following:

    PHP Code:
    case 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING':
    case 
    'NOTIFY_HEADER_START_CHECKOUT_PAYMENT':
    case 
    'NOTIFY_HEADER_START_CHECKOUT_CONFIRMATION':
        if (
    $prodincase && $bigcase 0) {
            if(
    $prodincase $bigcase != && $_SESSION['cart']->count_contents() != $smallcase) {
                
    zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
            }
        } 
    However, at this stage of the switch $prodincase hasn't been declared, so checkout pages were not redirecting if there was a conflict. I've replaced the above with this:

    PHP Code:
    case 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING':
    case 
    'NOTIFY_HEADER_START_CHECKOUT_PAYMENT':
    case 
    'NOTIFY_HEADER_START_CHECKOUT_CONFIRMATION':
        if(
    $_SESSION['cart']->count_contents() % $bigcase !=&& $_SESSION['cart']->count_contents() % $smallcase !=0){
            
    zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
        } 
    A big thanks to georgfly for providing the contrib in the first place.

  2. #2
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,266
    Plugin Contributions
    3

    Default Re: Assorted Wine Crates

    Could you point me to the download of this add-on pls...

    I wrote my own module for wine boxes some years ago (but it was clunky) and would like to see this one.
    20 years a Zencart User

  3. #3
    Join Date
    Aug 2008
    Posts
    9
    Plugin Contributions
    0

    Default Re: Assorted Wine Crates

    Current download location is http://www.zen-cart.com/downloads.php?do=file&id=1309 listed under the Product Types category.

    I think I just found another bug. Around line 62 of the original file is:

    PHP Code:
            if ($prodincase && $bigcase 0) {
              if(
    $prodincase $bigcase != && $prodincase != $smallcase) {
                
    $_SESSION['valid_to_checkout'] = false;
                
    $messageStack->add('shopping_cart'sprintf(TEXT_ORDER_UNDER_MIN_AMOUNT$bigcase$smallcase) . '<br />''caution');
              }
            } 
    Which I've changed to:
    PHP Code:
            $morethanbigcase $prodincase $bigcase;
            if (
    $prodincase && $bigcase 0) {
              if(
    $morethanbigcase != && $morethanbigcase != $smallcase) {
                
    $_SESSION['valid_to_checkout'] = false;
                
    $messageStack->add('shopping_cart'sprintf(TEXT_ORDER_UNDER_MIN_AMOUNT$bigcase$smallcase) . '<br />''caution');
              }
            } 

  4. #4
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,266
    Plugin Contributions
    3

    Default Re: Assorted Wine Crates

    Thanks a ton for the heads-up, and for your revisions. Much appreciated...
    20 years a Zencart User

  5. #5
    Join Date
    Apr 2011
    Posts
    10
    Plugin Contributions
    2

    Default Re: Assorted Wine Crates

    Thanks for your bug-fixes. The first one must indeed be a bug (i have modified this code slightly before i used it in my own shop, and 'accidently' gotten rid of it without ever realizing it...).
    For the second one, I guess it depends on what you need. My intention was to either allow customer to purchase a single case with 6 bottles, OR only multiples of 12 (I would not allow to purchase one case of 12 and one case of 6 in the same order). I havent tested it, but I seems you also want to allow mixed orders (multiples of 12 AND a single case of 6). Anyway, thanks for the fixes.

  6. #6
    Join Date
    Aug 2008
    Posts
    9
    Plugin Contributions
    0

    Default Re: Assorted Wine Crates

    No worries. Actually I found another bug, but was too busy to post a fix. From memory it was that the code after:
    PHP Code:
          case 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING':
          case 
    'NOTIFY_HEADER_START_CHECKOUT_PAYMENT':
          case 
    'NOTIFY_HEADER_START_CHECKOUT_CONFIRMATION'
    ...wasn't taking into consideration that there might be non-wine category items in the cart. Basically, we have to count everything again. So I've incorporated the following (from around line 69 in the original file):

    PHP Code:
          case 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING':
          case 
    'NOTIFY_HEADER_START_CHECKOUT_PAYMENT':
          case 
    'NOTIFY_HEADER_START_CHECKOUT_CONFIRMATION':
          
    // COUNT ALL WINE-CASE ITEMS IN CART
          
    $prodincase 0;
          
    $mycart $_SESSION['cart'];
          
    $myprodids $mycart->get_product_id_list();
          
    $myprodids explode(', '$myprodids);
          foreach(
    $myprodids as $myprodid) {
            
    $myprodpaths zen_get_product_path($myprodid);
            
    $myprodpaths explode('_'$myprodpaths);
            
    $iswine false;
            foreach(
    $myprodpaths as $myprodpath){
              foreach(
    $winecats as $winecat){
                if (
    $winecat == $myprodpath){
                  
    $iswine true;
                }
              }
            }
              if (
    $iswine){
              
    $prodincase $prodincase $mycart->get_quantity($myprodid);
              }
          }

            
    $morethanbigcase $prodincase $bigcase;
              
            if (
    $prodincase && $bigcase 0) {
              if(
    $morethanbigcase != && $morethanbigcase != $smallcase) {
                
    zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
              }
            }
            break;
          default:
            break;
        }
      }
    }
    ?> 

  7. #7
    Join Date
    Jan 2013
    Location
    Eustis, Florida, United States
    Posts
    84
    Plugin Contributions
    0

    Default Re: Assorted Wine Crates

    Does anyone know where I can download this for 1.5? I tried installing the version here http://www.zen-cart.com/downloads.php?do=file&id=1309 but when I tried to login I got a white screen so just reverted. Oh, maybe the fixes above will help? Appreciate your input and I will try the above things.

    I am also looking to use it for a pack with either 10, 18, 20, 26 or 28 items. Could someone point me as to what I would need to amend and where to have this mod work do this?
    Last edited by DeeL; 15 Mar 2013 at 03:33 AM.

  8. #8
    Join Date
    Aug 2008
    Posts
    9
    Plugin Contributions
    0

    Default Re: Assorted Wine Crates

    It's been months since I looked at this, but you'd want to look for anywhere $bigcase and $smallcase is mentioned in the observer class. Probably worth replacing those with an array for your needs.

  9. #9
    Join Date
    Jan 2013
    Location
    Eustis, Florida, United States
    Posts
    84
    Plugin Contributions
    0

    Default Re: Assorted Wine Crates

    Sorry, this is relatively new to me so what would I need to enter to define an array? The pack sizes I need are 10, 18, 20, 26 and 28. Do you know if it is possible to set a price for each of those pack sizes?

  10. #10
    Join Date
    Jan 2013
    Location
    Eustis, Florida, United States
    Posts
    84
    Plugin Contributions
    0

    Default Re: Assorted Wine Crates

    How do I define an array?

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v150 Wine attributes or features....
    By Good Bottle of Wine in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 26 Jul 2012, 01:54 PM
  2. Adding an Excel Spreadsheet of assorted trading cards to Your ZenCart site?
    By Jesse_Tyler in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 30 Aug 2006, 08:43 PM
  3. A Plethora Of Assorted Questions ......
    By FSGS in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 17 May 2006, 01:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg