Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2007
    Posts
    248
    Plugin Contributions
    6

    Default Ceon Advanced Shipper Restrict Categories on Shipping method

    So we have a few shipping method options available in advshipper, but found that we wanted to restrict certain methods for certain categories.
    Below is how we achieved it, bit mechanical, but it works.

    In mysql, copy the table and structure of the 'advshipper_method_categories' to a new table called 'advshipper_method_categories_exclude'

    For each method that you want to exclude for a category then add it in.
    for example i want to exclude method 2 for all products in category 274
    i simply insert: 1,2,1,274 to the table.

    in the includes/modules/shipping/advshipper.php

    around line 580 find:

    Code:
    // First, determine if this product is included in any specific shipping methods
                if ($use_product_selection_lookups) {
                    $product_specific_methods =
                        $this->_getProductSpecificShippingMethods($product_id, $product_attributes);
    
                    $product_methods = $product_specific_methods;
                }
    then after add:

    Code:
    $category_specific_methods =
                        $this->_getCategoryExcludeShippingMethods($product_id);
    
                        //
                        //$disabled_methods[] = $disabled_methods_result->fields['method'];
                        //
                        
                    for ($csm_i = 0, $num_csm = sizeof($category_specific_methods); $csm_i < $num_csm;
                            $csm_i++) {
                        if (!in_array($category_specific_methods[$csm_i], $disabled_methods)) {
                            $disabled_methods[] = $category_specific_methods[$csm_i];
                        }
                    }

    around line 1098 add:

    Code:
        function _getCategoryExcludeShippingMethods($product_id)
        {
            global $db;
    
            $category_specific_methods = array();
    
            // Get all categories this product is in
            $categories_for_product = array();
    
            $categories_for_product_query = "
                SELECT
                    DISTINCT categories_id
                FROM
                    " . TABLE_PRODUCTS_TO_CATEGORIES . "
                WHERE
                    products_id = '" . (int) $product_id . "';";
    
            $categories_for_product_result = $db->Execute($categories_for_product_query);
    
            while (!$categories_for_product_result->EOF) {
                $categories_for_product[] = $categories_for_product_result->fields['categories_id'];
    
                $categories_for_product_result->MoveNext();
            }
    
            if (sizeof($categories_for_product) > 0) {
                // Must get all sub-categories for the categories found
                $parent_categories = array();
    
                foreach ($categories_for_product as $category_id) {
                    zen_get_parent_categories($parent_categories, $category_id);
                }
    
                $categories_for_product = array_merge($categories_for_product, $parent_categories);
    
                $category_ids_string = implode(',', $categories_for_product);
    
                $check_methods_for_categories_sql = "
                    SELECT
                        DISTINCT asmc.method
                    FROM
                        advshipper_method_categories_exclude asmc
                    WHERE
                        asmc.config_id = '" . $this->_config_id . "'
                    AND
                        asmc.category_id IN (" . $category_ids_string . ")
                    ORDER BY
                        asmc.method;";
    
                $check_methods_for_categories_result = $db->Execute($check_methods_for_categories_sql);
    
                if ($check_methods_for_categories_result->EOF) {
                    // No methods specifically cover these categories
                } else {
                    while (!$check_methods_for_categories_result->EOF) {
                        $category_exclude_methods[] =
                            $check_methods_for_categories_result->fields['method'];
    
                        $check_methods_for_categories_result->MoveNext();
                    }
                }
            }
            return $category_exclude_methods;
            
        }

    thats it.

  2. #2
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Ceon Advanced Shipper Restrict Categories on Shipping method

    Why is it necessary to add this code (that has no associated admin control) when a fallover method would be ignored if the category was already associated elsewhere?

    Further what discussion was had with the commercial software provider, Ceon, about the issue and a supported way to work through this?
    Last edited by mc12345678; 13 Aug 2018 at 04:00 PM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Jan 2007
    Posts
    1,484
    Plugin Contributions
    10

    Default Re: Ceon Advanced Shipper Restrict Categories on Shipping method

    I would hope they incorporate this into their base code because it would be super helpful to exclude certain items, categories and/or manufacturers from methods. It seems like nothing has been updated/added/improved with the commercial mod at this time, though.

    Zen Cart and it's community are the best!!

  4. #4
    Join Date
    Mar 2007
    Posts
    248
    Plugin Contributions
    6

    Default Re: Ceon Advanced Shipper Restrict Categories on Shipping method

    Quote Originally Posted by mc12345678 View Post
    Why is it necessary to add this code (that has no associated admin control) when a fallover method would be ignored if the category was already associated elsewhere?

    Further what discussion was had with the commercial software provider, Ceon, about the issue and a supported way to work through this?
    Because fallover methods are still included, even if another method specifically set for a category is in place...
    so i have huge volumetric stuff in a particualr category, that also meets requirements for freeshippingmethod (also a fallover method) based on cost.
    However i dont want to include this category within the free shipping, and there is no other way to exclude it from coming up during checkout.

  5. #5
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Ceon Advanced Shipper Restrict Categories on Shipping method

    Quote Originally Posted by Calljj View Post
    Because fallover methods are still included, even if another method specifically set for a category is in place...
    so i have huge volumetric stuff in a particualr category, that also meets requirements for freeshippingmethod (also a fallover method) based on cost.
    However i dont want to include this category within the free shipping, and there is no other way to exclude it from coming up during checkout.
    Had me for a second as its been a bit since I've had to generate a new set of methods. Thing is and again going back to the definitions, a fallover method applies to a product or group of products if that set is not assigned to some other specific method. That means a fallover method is excluded if the product are included elsewhere.

    In relation to the two fallover methods above, if the category were specifically included in the one fallover method, then it would be excluded from the other... No additional code needed...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Jan 2007
    Posts
    1,484
    Plugin Contributions
    10

    Default Re: Ceon Advanced Shipper Restrict Categories on Shipping method

    Much faster to be able to exclude something specific instead of having to include everything else manually. For instance, if a category has a couple products that you do not want to be included in a method, instead of having to manually select all of the other products that you do want included, you can simply select the whole category and then exclude those items. It's much faster that way. Or, you include a manufacturer but exclude some of their specific products since they are maybe oversized and too expensive to ship free. When you have thousands of products, it is much, much easier to exclude sometimes.

    Zen Cart and it's community are the best!!

  7. #7
    Join Date
    Mar 2007
    Posts
    248
    Plugin Contributions
    6

    Default Re: Ceon Advanced Shipper Restrict Categories on Shipping method

    Quote Originally Posted by mc12345678 View Post
    Had me for a second as its been a bit since I've had to generate a new set of methods. Thing is and again going back to the definitions, a fallover method applies to a product or group of products if that set is not assigned to some other specific method. That means a fallover method is excluded if the product are included elsewhere.

    In relation to the two fallover methods above, if the category were specifically included in the one fallover method, then it would be excluded from the other... No additional code needed...

    Indeed that’s how I thought it worked but it’s not.
    I have 3 methods, two of them are fall over, have no specific products or categories set, shipping price based on weight and destination.
    The 3rd method is specific to a category which has extra large items, the items still ‘qualify’ within the weight range of the other 2 methods. Go to checkout and all 3 methods are displayed.

  8. #8
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Ceon Advanced Shipper Restrict Categories on Shipping method

    Quote Originally Posted by Calljj View Post
    Indeed that’s how I thought it worked but it’s not.
    I have 3 methods, two of them are fall over, have no specific products or categories set, shipping price based on weight and destination.
    The 3rd method is specific to a category which has extra large items, the items still ‘qualify’ within the weight range of the other 2 methods. Go to checkout and all 3 methods are displayed.
    I can't replicate this issue if setup as described of having two fallover methods and one method applied specifically to a product, category and/or manufacturer.

    I created four methods.
    1. specific product (product 1) applies to this method.
    2. free shipping for all items that do not have a method applied. (Fallover method no specific designated items)
    3. a shipping cost for all items that do not have a method applied. (Fallover method no specific designated items)
    4. specific category (category 1) (doesn't include the product in method 1 above) applies to this method.

    All methods were setup to apply to all locations and any number, price, weight, etc... of product to simplify the testing/demonstration. Having additional "criteria" such as weight, price, quantity, etc.. only limits (reduces) the possibility of using the method(s).

    Test 1: In the cart I added product 1, reviewed shipping options: method 1 shown. (as expected)
    Test 2: removed product 1, added a product from category 1, reviewed shipping options: method 4 only shown. (as expected)
    Test 3: removed product from category 1, added a product (let's call it product 2) that was not product 1 and not in category 1, reviewed shipping options: methods 2 and 3 shown. (as expected because these are fallover methods)

    Test 4: Modified method 3 to add the specific product (product 2) to it, and otherwise still applied to product that had no other method assigned.
    Now when again reviewing the shipping options (remember product in cart is product 2 which is not in category 1 and is not product 1), only method 3 was shown. (As expected and as described should occur that the free option would go away because the product was captured in a method).

    Test 5: Again modified method 3 to add category 1 to it, and otherwise still applied to product that had no other method assigned.
    Now when product 2 was removed and a product from category 1 was added, both methods 3 and 4 are shown.

    In the end I had this arrangement (in this sequence even)
    1. specific product (product 1) applies to this method.
    2. free shipping for all items that do not have a method applied. (Fallover method no specific designated items)
    3. a shipping cost for all items that do not have a method applied that also applies to product 2 (which is not in category 1) and also those of category 1. (Fallover method with two specific designated unique items of one product and one category)
    4. specific category (category 1) (category 1 doesn't include the product in method 1 above and doesn't include product 2) applies to this method.

    At no time did the free shipping option method get displayed for a product that was specifically included in another method (again by including in another method that product got excluded from the free shipping). The sequencing of the methods didn't matter (see tests 2, 4 and 5 where an "earlier" fallover method didn't get presented if product were assigned to a later method).
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    Jan 2013
    Posts
    811
    Plugin Contributions
    0

    Default Re: Ceon Advanced Shipper Restrict Categories on Shipping method

    i have mine to show this method if all products in stock or
    show this method if all products not in stock or
    show this method if all products are in stock and nonstock
    and all can be setup in admin

 

 

Similar Threads

  1. v151 Ceon Advanced Shipper - how can I limit the display of available shipping methods?
    By dysfunctional in forum Addon Shipping Modules
    Replies: 4
    Last Post: 31 Jan 2015, 04:03 AM
  2. v151 Ceon Advanced Shipper v5.02 Updated to include freightquote.com shipping
    By jimmie in forum Addon Shipping Modules
    Replies: 3
    Last Post: 18 Dec 2014, 01:48 PM
  3. v150 CEON Adv Shipper vs Amazon Checkout -- shipping method names
    By WebKat in forum Addon Payment Modules
    Replies: 5
    Last Post: 9 Nov 2012, 06:51 PM
  4. Ceon Advanced Shipper
    By Danielle in forum Addon Shipping Modules
    Replies: 2
    Last Post: 20 Jul 2010, 05:03 PM
  5. Ceon Advanced Shipper
    By pasher in forum Addon Shipping Modules
    Replies: 6
    Last Post: 15 Jul 2008, 09:00 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR