Forums / Managing Customers and Orders / How to get Shipping costs from DB

How to get Shipping costs from DB

Locked

Views: 2,801

Results 1 to 14 of 14
This thread is locked. New replies are disabled.
12 Aug 2006, 9:29 PM
#1
rgoetz avatar

rgoetz

New Zenner

Join Date:
Aug 2006
Posts:
36
Plugin Contributions:
0

How to get Shipping costs from DB

Hi, I've managed to get my sql statements to pull the order information from the database. The only thing I cannot seem to get is the shipping cost. I get shipping type, shipping module code, but not the amount for shipping.

Where can I find this? It does not seem to be in orders?

Rhonda

13 Aug 2006, 3:04 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: How to get Shipping costs from DB

The orders_total table contains your subtotal details for each order

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

13 Aug 2006, 3:07 AM
#3
rgoetz avatar

rgoetz

New Zenner

Join Date:
Aug 2006
Posts:
36
Plugin Contributions:
0

Re: How to get Shipping costs from DB

HI, I've pulled everything from the orders table, it gives me total order, price and quantity, but no shipping. Does zencart perform a calculation to get that info?

Rhonda

13 Aug 2006, 4:05 AM
#4
wolfsz avatar

wolfsz

Zen Follower

Join Date:
Mar 2006
Location:
Australia
Posts:
286
Plugin Contributions:
3

Re: How to get Shipping costs from DB

Hi there
As was mentioned in the previous post, the info is in zen_orders_total not zen_orders!

Wolf Skafte-Zauss
http://e-commerce-pros.com
Tools for E-commerce Professionals

13 Aug 2006, 11:06 AM
#5
rgoetz avatar

rgoetz

New Zenner

Join Date:
Aug 2006
Posts:
36
Plugin Contributions:
0

Re: How to get Shipping costs from DB

Sorry, I also pulled the text, title, class, value, id, everything and no shipping costs. What am I doing wrong?

Here is my sql query:

SELECT
orders.date_purchased,
orders.orders_id,
orders.customers_name,
orders.customers_company,
orders.customers_street_address,
orders.customers_suburb,
orders.customers_state,
orders.customers_postcode,
orders.customers_city,
orders.customers_id,
orders.customers_country,
orders.customers_telephone,
orders.customers_email_address,
orders.delivery_name,
orders.delivery_company,
orders.delivery_street_address,
orders.delivery_suburb,
orders.delivery_city,
orders.delivery_postcode,
orders.delivery_state,
orders.delivery_country,
orders.billing_name,
orders.billing_suburb,
orders.billing_street_address,
orders.billing_company,
orders.billing_city,
orders.billing_postcode,
orders.billing_state,
orders.currency,
orders.order_tax,
orders.order_total,
orders.billing_country,
orders.payment_method,
orders.shipping_method,
orders.shipping_module_code,
orders.orders_date_finished,
orders_products.orders_products_id,
orders_products.products_name,
orders_products.products_quantity,
orders_products_attributes.products_options,
orders_products_attributes.products_options_values,
orders_total.orders_total_id,
orders_total.text,
orders_total.value
orders_total.class
FROM
orders
Inner Join orders_products ON orders.orders_id = orders_products.orders_id
Inner Join orders_products_attributes ON orders_products.orders_id = orders_products_attributes.orders_id
Inner Join orders_total ON orders.orders_id = orders_total.orders_id
GROUP BY
orders.date_purchased

I am new at this, so I may have something wrong. I just need to get all the order information out along with attributes and the kitchen sink!

Rhonda

13 Aug 2006, 11:16 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: How to get Shipping costs from DB

if you look at the orders_total table, you'll see it's a many-to-many relationship.

If you're going to attempt a join query as you've indicated, you'll need to restrict your returned values by limiting to just the ot_shipping class.

Further, your join for attributes is preventing you from returning results if the orders don't have any attributes selected in them.

However, this works, without attributes details:```
SELECT
orders.date_purchased,
orders.orders_id,
orders.customers_name,
orders.customers_company,
orders.customers_street_address,
orders.customers_suburb,
orders.customers_state,
orders.customers_postcode,
orders.customers_city,
orders.customers_id,
orders.customers_country,
orders.customers_telephone,
orders.customers_email_address,
orders.delivery_name,
orders.delivery_company,
orders.delivery_street_address,
orders.delivery_suburb,
orders.delivery_city,
orders.delivery_postcode,
orders.delivery_state,
orders.delivery_country,
orders.billing_name,
orders.billing_suburb,
orders.billing_street_address,
orders.billing_company,
orders.billing_city,
orders.billing_postcode,
orders.billing_state,
orders.currency,
orders.order_tax,
orders.order_total,
orders.billing_country,
orders.payment_method,
orders.shipping_method,
orders.shipping_module_code,
orders.orders_date_finished,
orders_products.orders_products_id,
orders_products.products_name,
orders_products.products_quantity,
orders_total.orders_total_id,
orders_total.text,
orders_total.value,
orders_total.class
FROM
orders
Inner Join orders_products ON orders.orders_id = orders_products.orders_id
Inner Join orders_total ON orders.orders_id = orders_total.orders_id AND orders_total.class = 'ot_shipping'
GROUP BY
orders.date_purchased;

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

13 Aug 2006, 3:23 PM
#7
rgoetz avatar

rgoetz

New Zenner

Join Date:
Aug 2006
Posts:
36
Plugin Contributions:
0

Re: How to get Shipping costs from DB

Oh thank you so much. I looked through this board for a query that would give me all the information I needed and couldn't find one. That is the ticket!

Thanks, Rhonda

13 Aug 2006, 3:37 PM
#8
rgoetz avatar

rgoetz

New Zenner

Join Date:
Aug 2006
Posts:
36
Plugin Contributions:
0

Re: How to get Shipping costs from DB

Oops, still need more help. All my attributes info is gone.

Also, I am geting everything I want except for the multiple items a customer orders. How do I get all the items for each customer? I assume that I messed up the query again...

Thank you,

Rhonda

13 Aug 2006, 6:59 PM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: How to get Shipping costs from DB

What EXACTLY are you trying to accomplish?

Pulling an order record (a single entity) is completely different than pulling a list of all items purchased on that order (multiple entities).

How about running a separate query to pull a list of purchased items?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

13 Aug 2006, 9:52 PM
#10
rgoetz avatar

rgoetz

New Zenner

Join Date:
Aug 2006
Posts:
36
Plugin Contributions:
0

Re: How to get Shipping costs from DB

I need the following information in one file:

All the customer order info
Each product the customer ordered and its quantity, cost, tax, shipping cost, and attributes.
The total of the order
Purchase type: credit/check
Date purchased

I've been really challenged trying to get an order info export with everything in it. There are modules, but they only pull some of the info.

Any help you can give me, I will greatly appreciate it!

Rhonda

14 Aug 2006, 10:45 PM
#11
rgoetz avatar

rgoetz

New Zenner

Join Date:
Aug 2006
Posts:
36
Plugin Contributions:
0

Re: How to get Shipping costs from DB

Can anyone help me with this? I need the sql query to make this happen correctly.

I need to get the exported data out ASAP.

**I need the following information in one file:

All the customer order info
Each product the customer ordered and its quantity, cost, tax, shipping cost, and attributes.
The total of the order
Purchase type: credit/check
Date purchased

I've been really challenged trying to get an order info export with everything in it. There are modules, but they only pull some of the info.**

I've searched all over for an answer and can only find partial ones here and there.

15 Aug 2006, 3:52 AM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: How to get Shipping costs from DB

When you say "one file" what EXACTLY do you mean?
Are you referring to something that would look like a spreadsheet with all the fields showing across the page?
If so, then how are you expecting all the product-details to show up?

You WILL NEED to do this in multiple steps.

Query 1-OrderSummary: Name, Address, Date, Amount, Shipping-Cost Shipping-Method, Taxes-Paid, Pmt-Type etc
**Query 2-ProductDetails: ** Product Name, Quantity, Price,
Query 3-AttribDetails: Attributes

Hence a PHP-based reporter is more likely to produce the output you need.

Granted, you haven't stated "why" you need this ... what is going to read this "one file" you mention? What is your purpose in pulling this information?

As an aside, if you are quoting text from a forum post, please use [ quote ] tags around them instead of [ bold ] tags ... otherwise it looks like you're shouting. The little yellow "callout" icon in the editor will put those tags around selected text automatically, and so will pressing the "quote" button on an existing post.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

15 Aug 2006, 1:32 PM
#13
rgoetz avatar

rgoetz

New Zenner

Join Date:
Aug 2006
Posts:
36
Plugin Contributions:
0

Re: How to get Shipping costs from DB

Yes I need this to be in an excel spreadsheet with all the info running across.

My client wants it in this form for his records. The list will be printed out for use.

example if a customer purchases more than one item.

customer 225 shoes size 8 color blue Quantity: 1 Cost: 100.00 tax: $8.75 shipping: 12.95
customer 225 shoes size 8 color red Quantity: 1 Cost: 100.00 tax: $8.75 shipping: 12.95

Thanks for the reminder about the quotes, I completely forgot.

Thank you for your patience and your help.

Rhonda

18 Aug 2006, 7:49 AM
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: How to get Shipping costs from DB

that will certainly be an interesting query ...

Once again, you might be better off using PHP to pull the data and dump it to a CSV or tab-delimited file which could be printed or imported to a spreadsheet

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.