Zen Cart Logo
Forums / Addon Shipping Modules / Shipping, Product Category, Question

Shipping, Product Category, Question

Locked

Views: 2,132

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
15 Nov 2006, 5:21 PM
#1
omnipotententity avatar

omnipotententity

New Zenner

Join Date:
Sep 2006
Posts:
17
Plugin Contributions:
0

Shipping, Product Category, Question

Is there a Quick and Easy way to access the categories of the products purchased?

The reason I ask is the person I'm working for has a crazy shipping scheme. And if all the products are in one category it qualifies for another shipping type.

I've been looking at the $order variable, but it doesn't seem to contain information about the category type.

15 Nov 2006, 6:45 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping, Product Category, Question

You could verify the categories_id of each product ...

Does this client use or intend to use Linked Products? Or will all Products always be in 1 Category and ONLY 1 Category?

15 Nov 2006, 7:32 PM
#3
omnipotententity avatar

omnipotententity

New Zenner

Join Date:
Sep 2006
Posts:
17
Plugin Contributions:
0

Re: Shipping, Product Category, Question

God I hope not...

I was also hoping to not have to do any extra queries if I didn't have to. I was just wondering if it was already sitting in a variable somewhere that was accessable from the shipping modules.

15 Nov 2006, 7:36 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping, Product Category, Question

This is not built into Zen Cart at this time for the Shipping Modules ...

You would need to do some custom coding ...

15 Nov 2006, 8:09 PM
#5
omnipotententity avatar

omnipotententity

New Zenner

Join Date:
Sep 2006
Posts:
17
Plugin Contributions:
0

Re: Shipping, Product Category, Question

I know that. The question I'm trying to ask is: is the category_id of the products under $order->products sitting in $order somewhere or another variable? Or do I need to add it in /includes/classes/order.php?

15 Nov 2006, 8:16 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping, Product Category, Question

It is not in the orders anything ...

You could, if the products are NOT Linked, use the master_categories_id to check this ...

You could build a function to check what categories the products are in and send back a true or false on whether or not they are all in the same category ...

Get a list of products from the shopping_cart and do a quick look up of the category ... using a quick loop, you can verify whether or not these are all in the same category ...

Even if you use Linked Products this can still be done with a function for verification ...

There are several methods to address this ... but you do need to make sure about the Linked Products issue ...

11 Dec 2006, 9:59 PM
#7
omnipotententity avatar

omnipotententity

New Zenner

Join Date:
Sep 2006
Posts:
17
Plugin Contributions:
0

Re: Shipping, Product Category, Question

After a lengthy hiatus I've come back to this problem.

I've made the following changes to the code (1.3.5): (Link to the edited version, if you don't know how or care to apply the diff: here)

155,162c155,173
<     $orders_products_query = "select orders_products_id, products_id, products_name,
<                                  products_model, products_price, products_tax,
<                                  products_quantity, final_price,
<                                  onetime_charges,
<                                  products_priced_by_attribute, product_is_free, products_discount_type,
<                                  products_discount_type_from
<                                   from " . TABLE_ORDERS_PRODUCTS . "
<                                   where orders_id = '" . (int)$order_id . "'";
---
>
>     $orders_products_query = "select " . TABLE_ORDERS_PRODUCTS . ".orders_products_id as orders_products_id, "
>                                        . TABLE_ORDERS_PRODUCTS . ".products_id as products_id, "
>                                        . TABLE_ORDERS_PRODUCTS . ".products_name as products_name, "
>                                        . TABLE_ORDERS_PRODUCTS . ".products_model as products_model, "
>                                        . TABLE_ORDERS_PRODUCTS . ".products_price as products_price, "
>                                        . TABLE_ORDERS_PRODUCTS . ".products_tax as products_tax, "
>                                        . TABLE_ORDERS_PRODUCTS . ".products_quantity as products_quantity, "
>                                        . TABLE_ORDERS_PRODUCTS . ".final_price as final_price, "
>                                        . TABLE_ORDERS_PRODUCTS . ".onetime_charges as onetime_charges, "
>                                        . TABLE_ORDERS_PRODUCTS . ".products_priced_by_attribute as products_priced_by_attribute, "
>                                        . TABLE_ORDERS_PRODUCTS . ".product_is_free as product_is_free, "
>                                        . TABLE_ORDERS_PRODUCTS . ".products_discount_type as products_discount_type, "
>                                        . TABLE_ORDERS_PRODUCTS . ".products_discount_type_from as products_discount_type_from, "
>                                        . TABLE_PRODUCTS . ".master_categories_id as master_categories_id "
>                                   . " from " . TABLE_ORDERS_PRODUCTS .
>                                   " left join " . TABLE_PRODUCTS .
>                                   " on " . TABLE_ORDERS_PRODUCTS. ".products_id = " . TABLE_PRODUCTS . ".products_id "
>                                   . TABLE_ORDERS_PRODUCTS . "where orders_id = '" . (int)$order_id . "'";
199c210,211
<                                       'products_discount_type_from' => $orders_products->fields['products_discount_type_from']);
---
>                                       'products_discount_type_from' => $orders_products->fields['products_discount_type_from'],
>                                       'master_categories_id' => $orders_products->fields['master_categories_id']);
433a446
>                                       'master_categories_id' => $products[$i]['master_categories_id'],
727a741
>                               'master_categories_id' => $this->products[$i]['master_categories_id'],
981c995
< ?>
\ No newline at end of file
---
> ?>

I went ahead and did a print_r on the object when it's passed to the shipping estimator, and I got this:

order Object
(
    [observers] => Array
        (
        )

    [info] => Array
        (
            [order_status] => 1
            [currency] => USD
            [currency_value] => 1.00000000
            [payment_method] => 
            [payment_module_code] => 
            [coupon_code] => 
            [shipping_method] => 
            [shipping_module_code] => 
            [shipping_cost] => 
            [subtotal] => 39.97
            [tax] => 0
            [total] => 39.97
            [tax_groups] => Array
                (
                    [Sales Tax] => 0
                )

            [comments] => 
            [ip_address] => 255.255.255.255
        )

    [totals] => Array
        (
        )

    [products] => Array
        (
            [0] => Array
                (
                    [qty] => 1
                    [name] => Jon Amraphel At Early Morning Practice Print
                    [model] => 
                    [tax] => 0
                    [tax_description] => Sales Tax
                    [price] => 10.0000
                    [final_price] => 10
                    [onetime_charges] => 0
                    [weight] => 0.5
                    [products_priced_by_attribute] => 0
                    [product_is_free] => 0
                    [products_discount_type] => 0
                    [products_discount_type_from] => 0
                    [master_categories_id] => 
                    [id] => 19
                    [rowClass] => rowEven
                )

            [1] => Array
                (
                    [qty] => 2
                    [name] => Exploitation Now, Volume Two
                    [model] => 
                    [tax] => 0
                    [tax_description] => Sales Tax
                    [price] => 9.9900
                    [final_price] => 9.99
                    [onetime_charges] => 0
                    [weight] => 0.382
                    [products_priced_by_attribute] => 0
                    [product_is_free] => 0
                    [products_discount_type] => 0
                    [products_discount_type_from] => 0
                    [master_categories_id] => 
                    [id] => 57
                    [rowClass] => rowOdd
                )

            [2] => Array
                (
                    [qty] => 1
                    [name] => Errant Story, Volume Two
                    [model] => 
                    [tax] => 0
                    [tax_description] => Sales Tax
                    [price] => 9.9900
                    [final_price] => 9.99
                    [onetime_charges] => 0
                    [weight] => 0.5625
                    [products_priced_by_attribute] => 0
                    [product_is_free] => 0
                    [products_discount_type] => 0
                    [products_discount_type_from] => 0
                    [master_categories_id] => 
                    [id] => 4
                    [rowClass] => rowEven
                )

        )

    [customer] => Array
        (
            [firstname] => Michael
            [lastname] => Reilly
            [company] => 
            [street_address] => 143 Scottwood Dr
            [suburb] => 
            [city] => Ft. Walton Beach
            [postcode] => 32548
            [state] => Florida
            [zone_id] => 18
            [country] => Array
                (
                    [id] => 223
                    [title] => United States
                    [iso_code_2] => US
                    [iso_code_3] => USA
                )

            [format_id] => 2
            [telephone] => 850-555-5555
            [email_address] => [email protected]
        )

    [delivery] => Array
        (
            [firstname] => Michael
            [lastname] => Reilly
            [company] => 
            [street_address] => 123 Anonymous Way
            [suburb] => 
            [city] => The Burbs
            [postcode] => 12321
            [state] => Florida
            [zone_id] => 18
            [country] => Array
                (
                    [id] => 223
                    [title] => United States
                    [iso_code_2] => US
                    [iso_code_3] => USA
                )

            [country_id] => 223
            [format_id] => 2
        )

    [content_type] => physical
    [email_low_stock] => 
    [products_ordered_attributes] => 
    [products_ordered] => 
    [products_ordered_email] => 
    [billing] => Array
        (
            [firstname] => 
            [lastname] => 
            [company] => 
            [street_address] => 
            [suburb] => 
            [city] => 
            [postcode] => 
            [state] => 
            [zone_id] => 
            [country] => Array
                (
                    [id] => 
                    [title] => 
                    [iso_code_2] => 
                    [iso_code_3] => 
                )

            [country_id] => 
            [format_id] => 
        )

)

The one I added (master_categories_id) is coming up null, and I don't believe it's the query, I think I missed something I have to edit or something. Any ideas?

14 Dec 2006, 9:17 PM
#8
omnipotententity avatar

omnipotententity

New Zenner

Join Date:
Sep 2006
Posts:
17
Plugin Contributions:
0

Re: Shipping, Product Category, Question

No takers at all?