Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Zero weight skips shipping page


Guest

Recommended Posts

I run a highly modified cart and have both shipping and download products. I am not using attributes or the download mod (products require registration, no need to protect the download files).

 

Anyway, after searching the boards here without finding an answer and then a bit of head scratching I realized a simple mod could make orders that have a zero weight (ie, all products were download only) skip the shipping page. Since I had not found this answer in my search I thought I'd post my solution for others.

 

In 'checkout_shipping.php' find the lines here:

 

// if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
 if (($order->content_type == 'virtual') || ($order->content_type == 'virtual_weight')) {
   if (!tep_session_is_registered('shipping')) tep_session_register('shipping');
   $shipping = false;
   $sendto = false;
   tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
 }

 $total_weight = $cart->show_weight();
 $total_count = $cart->count_contents();

and replace them with this:

 

// IFD MOD_SQUAD BEGIN: zero weight should skip shipping page

 $total_weight = $cart->show_weight();
 $total_count = $cart->count_contents();

// if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
 if (($order->content_type == 'virtual') ||
     ($order->content_type == 'virtual_weight') ||
     ($total_weight == 0 ) {
   if (!tep_session_is_registered('shipping')) tep_session_register('shipping');
   $shipping = false;
   $sendto = false;
   tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
 }
// IFD MOD_SQUAD BEGIN

Link to comment
Share on other sites

  • 3 weeks later...

I'm always thankful for people that take time to post solutions to problems we all have. Thanks Lane! This is exactly what I was looking for and it works a charm! We sometimes include free shipping on specials we run, and this works perfect to bypass the shipping screen when the item's weight is set to zero.

 

One suggestion, if I may. The code was missing a closing ')' :

 

As is listed above:

 

  if (($order->content_type == 'virtual') ||
    ($order->content_type == 'virtual_weight') ||
    ($total_weight == 0 ) {

 

Should be:

 

  if (($order->content_type == 'virtual') ||
    ($order->content_type == 'virtual_weight') ||
    ($total_weight == 0 )) {

 

Thanks again!

Link to comment
Share on other sites

You are correct ... my bad in editing the code to be more readable in this message (the actual code is all one line).

 

Glad someone else found it of use :)

Link to comment
Share on other sites

  • 2 months later...
  • 3 weeks later...
This is ok, but it skips info needed for shipping address....Might be needed...

 

Actually, that's the who purpose of the mod, to skip the shipping entry screen for products that have no weight (ie, if there is no weight there is nothing to ship).

Link to comment
Share on other sites

Actually, that's the who purpose of the mod, to skip the shipping entry screen for products that have no weight (ie, if there is no weight there is nothing to ship).

 

Great contri

 

I think what he is saying is that by being to set a product to zero weight, you can also use it for promotional reasons or for products that weigh nothing, cost little, but minimum shipping charges would kill it. You still need to be able to put in a shipping address if necessary.

 

The situation I have run into is that I just realized that by setting zero weight, for some reason I also get the tax NOT being charged. I use the Canada Post shipping module.

 

 

Any ideas on how I have zero weight to incur free shipping BUT still charge sales tax?

 

Thanks you thank you

Link to comment
Share on other sites

Hmm.... that's a good question! I don't have time to look at it now, xmas and all :D

 

But, I will put it on my TODO list... probably after the 1st unfortunately.

 

Great contri

 

I think what he is saying is that by being to set a product to zero weight, you can also use it for promotional reasons or for products that weigh nothing, cost little,  but minimum shipping charges would kill it. You still need to be able to put in a shipping address if necessary.

 

The situation I have run into is that I just realized that by setting zero weight, for some reason I also get the tax NOT being charged. I use the Canada Post shipping module.

Any ideas on how I have zero weight to incur free shipping BUT still charge sales tax?

 

Thanks you thank you

Link to comment
Share on other sites

  • 3 weeks later...
Hmm.... that's a good question! I don't have time to look at it now, xmas and all :D

 

But, I will put it on my TODO list... probably after the 1st unfortunately.

 

Can it be done ASAP please? I've tried to understand how all functions and arrays work but ends up with fetching arrays when expecting strings and vice vers. :(.

Link to comment
Share on other sites

Can it be done ASAP please? I've tried to understand how all functions and arrays work but ends up with fetching arrays when expecting strings and vice vers. :(.

 

I have looked into this more and I'm not sure what the goal is in this request. Here is my thinking:

 

1. This contribution is to allow zero weight items skip the shipping page. The only time you'd want to do this is if the product is not going to be shipped (ie, it's going to be downloaded for example). If you are not shipping something then there is no tax. At least that's my understanding, and it's how the OSC system works; nothing shipped means no tax is calculated.

 

2. You are wanting to have zero weight items be free to ship, but still ship them. Basically, this is how OSC works to start with, no need to install this contribution.

 

So my question is ... why install this contribution?

 

Hopefully your answer(s) will allow me to see the solution :D

Link to comment
Share on other sites

2. You are wanting to have zero weight items be free to ship, but still ship them. Basically, this is how OSC works to start with, no need to install this contribution.

 

So my question is ... why install this contribution?

 

First off I needed something to give me new glasses and tools to play with to get my OSC installation working as its expected. This contribution almost matched it, meaning I've been forced to do less adjustments and changes than expected.

 

The problem is that my shop is setup to work a bit different incase you are:

1) Shopping through the internet.

2) Working as clerk in the store taking orders over counter. (Nothing has 0 weight.)

 

With option 2) I need to send the correct address so it gets printed on the receipt (checkout page) without me having to handcode a couple of if..then and various things about various flags set in the customer database.

 

In short, it will save me immense work and a lot of headache to get everything working correctly :).

 

Is this a reason good enough? :)

Link to comment
Share on other sites

First off I needed something to give me new glasses and tools to play with to get my OSC installation working as its expected. This contribution almost matched it, meaning I've been forced to do less adjustments and changes than expected.

 

The problem is that my shop is setup to work a bit different incase you are:

1) Shopping through the internet.

2) Working as clerk in the store taking orders over counter. (Nothing has 0 weight.)

 

With option 2) I need to send the correct address so it gets printed on the receipt (checkout page) without me having to handcode a couple of if..then and various things about various flags set in the customer database.

 

In short, it will save me immense work and a lot of headache to get everything working correctly :).

 

Is this a reason good enough? :)

 

OK... I'm still not quite understanding your needs; so a few more questions are in order;

 

I read your reply as saying that 1 (shopping on internet) should have zero weight and no shipping, and that 2 (shopping at a physical store) should have shipping? I don't understand this, it would seem to me that you really want:

 

1) Shopping on internet (all items have weight and shipping address required)

 

2) Shopping in store (clerk takes order at counter, no shipping needed)

 

Actually, in either case it seems you have:

 

a> Shopping on internet

 

b> Shopping in a physical store

 

And that one of <a/b> needs to have shipping information and the other not. Now, if you want the shipping information, do you also want to charge for that shipping?

 

I'm assuming you are talking about having the same product ordered in both manners, where depending on _where_ the product is ordered shipping address (and charges?) are required. Correct?

 

Maybe you could direct me to a website or give me an example of a purchase experience from each method you envision?

Link to comment
Share on other sites

OK... I'm still not quite understanding your needs; so a few more questions are in order;

 

I read your reply as saying that 1 (shopping on internet) should have zero weight and no shipping, and that 2 (shopping at a physical store) should have shipping? I don't understand this, it would seem to me that you really want:

 

1) Shopping on internet (all items have weight and shipping address required)

 

2) Shopping in store (clerk takes order at counter, no shipping needed)

 

Actually, in either case it seems you have:

 

a> Shopping on internet

 

b> Shopping in a physical store

 

And that one of <a/b> needs to have shipping information and the other not. Now, if you want the shipping information, do you also want to charge for that shipping?

 

I'm assuming you are talking about having the same product ordered in both manners, where depending on _where_ the product is ordered shipping address (and charges?) are required. Correct?

 

Maybe you could direct me to a website or give me an example of a purchase experience from each method you envision?

 

Ok, I'll try and sum it up for you.

 

The clerk logs in to the store as any customer. The thing is that every purchase the clerks customer in the DB performs should be given free shipping without even given that option. That's what your contribution did for me, all I had to do was to tweak and fix so that your contribution seemed flawlessly implemented in my OSC.

 

I need the adress being submitted to the checkout_confirm-page since the clerks adress (which is the stores) should be printed correctly on the receipt on the printer. With your solution I had to modify my includes/functions/general.php to avoid displaying a error on the checkout_confirm-page below Billing Adress.

 

Error given:

Warning: htmlspecialchars() expects parameter 1 to be string, array given in /secret_path/includes/functions/general.php on line 41

 

Forced me to this change of the function:

  function tep_output_string($string, $translate = false, $protected = false) {
   if ($protected == true) {
     if (is_array($string)) {
       return null;
     } else {
       return htmlspecialchars($string);
     }
   } else {
     if ($translate == false) {
       return tep_parse_input_field_data($string, array('"' => '"'));
     } else {
       return tep_parse_input_field_data($string, $translate);
     }
   }
 }

 

What I could see when I bughunted, one array with two sets of data was sent in the array containing shipping adress. With the above changes nothing is written to the page and thus empty even on receipt.

 

Now I have to enter hard data in the various files in order to display correct customer address unless I can get a string containing address sent instead of an array.

 

You understand now? And any store that has receipts/invoices made from purchases made over OSC ought to be happy to have the address included in the data sent to confirm the purchase.

 

Is this helping you?

Link to comment
Share on other sites

The basic problem is that you want a shipping address, and my mod is designed to bypass the shipping address entry entirely.

 

I actually can't see how to create a mod that could handle, in one store with one set of data, a customer ordering and having to give shipping information and get charged shipping while at the same time allowing a clerk to login as that customer, place an order yet not enter shipping information or be charged shipping but still somehow get the customer's shipping address so it can be printed on the receipt.

 

It may sound simple, but what you have here is a very complex need; this is where I hire professionals :thumbsup:

 

Ok, I'll try and sum it up for you.

 

The clerk logs in to the store as any customer. The thing is that every purchase the clerks customer in the DB performs should be given free shipping without even given that option. That's what your contribution did for me, all I had to do was to tweak and fix so that your contribution seemed flawlessly implemented in my OSC.

 

I need the adress being submitted to the checkout_confirm-page since the clerks adress (which is the stores) should be printed correctly on the receipt on the printer. With your solution I had to modify my includes/functions/general.php to avoid displaying a error on the checkout_confirm-page below Billing Adress.

 

Error given:

Warning: htmlspecialchars() expects parameter 1 to be string, array given in /secret_path/includes/functions/general.php on line 41

 

Forced me to this change of the function:

  function tep_output_string($string, $translate = false, $protected = false) {
   if ($protected == true) {
     if (is_array($string)) {
       return null;
     } else {
       return htmlspecialchars($string);
     }
   } else {
     if ($translate == false) {
       return tep_parse_input_field_data($string, array('"' => '"'));
     } else {
       return tep_parse_input_field_data($string, $translate);
     }
   }
 }

 

What I could see when I bughunted, one array with two sets of data was sent in the array containing shipping adress. With the above changes nothing is written to the page and thus empty even on receipt.

 

Now I have to enter hard data in the various files in order to display correct customer address unless I can get a string containing address sent instead of an array.

 

You understand now? And any store that has receipts/invoices made from purchases made over OSC ought to be happy to have the address included in the data sent to confirm the purchase.

 

Is this helping you?

Link to comment
Share on other sites

I actually can't see how to create a mod that could handle, in one store with one set of data, a customer ordering and having to give shipping information and get charged shipping while at the same time allowing a clerk to login as that customer, place an order yet not enter shipping information or be charged shipping but still somehow get the customer's shipping address so it can be printed on the receipt.

 

It may sound simple, but what you have here is a very complex need; this is where I hire professionals

 

Yepp. And since I am the professional in this matter, I just have to bite the apple and get coding ^^. I don't think there are many unedited files in my OSC in its current state :).

Link to comment
Share on other sites

  • 8 months later...

Zero weight skips payment?

 

I'd like to modify this bit of nifty code to skip both the shipping and the payment pages and go direct to checkout_confirmation.php. The reason for this is to sell to wholesale customers whose shipping is included with the purchase price and whose payment terms are set and will be handled offline. I've already set up Separate Pricing Per Customer, Hide Products from Customer Groups with SPPC, and an Add Multiple Items to Cart mod that together has me almost where I want to be. With this mod it's down to just a few steps for a wholesale customer to checkout- hopefully I can eliminate checkout_payment.php next.

 

My first thought on this would be to just change the instance of FILENAME_CHECKOUT_PAYMENT in the code for this mod to FILENAME_CHECKOUT_CONFIRMATION.

 

After testing this I found it caused the checkout process to get stuck in a loop so I commented out the following code in checkout_confirmation.php:

 

if ( ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL'));
 }

 

Unfortunately now I'm seeing

Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/content/t/e/s/testsite62/html/includes/functions/general.php on line 43

Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/content/t/e/s/testsite62/html/includes/functions/general.php on line 43

on checkout_confirmation.php.

 

I can feel myself slowly sinking ever deeper into the code....

 

If anyone has any ideas on this one, I'll buy you a virtual beer. :D

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

I'm not sure you can skip the payment pages without some extra coding; for sure you can't skip to the confirmation page (because there's nothing to confirm, so the parameters that page expects are empty). You might be able to fake the payment page with some hidden fields?

Link to comment
Share on other sites

I'm not sure you can skip the payment pages without some extra coding; for sure you can't skip to the confirmation page (because there's nothing to confirm, so the parameters that page expects are empty). You might be able to fake the payment page with some hidden fields?

This is exactly what I've been trying to do, but unfortunately can't seem to get it right.

 

Anybody manage to skip the payment page, and produce a correct result on the confirmation/checkout? :unsure:

Link to comment
Share on other sites

This is exactly what I've been trying to do, but unfortunately can't seem to get it right.

 

Anybody manage to skip the payment page, and produce a correct result on the confirmation/checkout? :unsure:

 

Yes.

 

I installed the code for Zero Weight Skips Shipping on checkout_shipping.php as instructed (also commented out the original 'if the order contains only virtual products, forward the customer to the billing page" section as it didn't work that way anyway).

 

Then, I put the Zero Weight Skips Shipping code on checkout_payment.php and changed the destination to checkout_confirmation. I put the code directly above the line that reads "// load all enabled payment modules".

 

As a result of this, upon clicking the checkout button or link, the customer is taken directly to the checkout_confirmation page where product totals, billing information, and payment method are all displayed (how, you may ask? Magic as far as I can tell- but I know the payment page has already loaded the billing information by the time it gets to the IFD code and I've only enabled one payment method for this payment group, thanks to SPPC, and this gets loaded early on too).

 

Upon clicking "confirm order" the order is submitted to the database, and originally I was seeing this error:

 

Warning: Invalid argument supplied for foreach() in checkout_process.php on line 129

Warning: Cannot modify header information - headers already sent by (output started at checkout_process.php:129) in includes/functions/general.php on line 30

 

The code in question is part of MVS and I don't know if it replaced something or is something new, but I just stuck the whole thing inside

if (($total_weight > 0 ) || ($shipping_array = $shipping['vendor'])){   
}

and called it a day, because at this point the customer sees the checkout_success.php and everyone is happy.

 

The only problem I have with it as far as I can tell right now is that the "edit" page of admin/orders.php is a mess (looking for a bunch of information that doesn't exist).

 

 

 

Also, I ended up not commenting out that bit of code from checkout_confirmation.php that I mentioned in my first post as causing me problems. I made it look like so:

 

 if ( ($total_weight > 0) && ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) {
  tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL'));
 }

 

It works!

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

I put the Zero Weight Skips Shipping code on checkout_payment.php and changed the destination to checkout_confirmation. I put the code directly above the line that reads "// load all enabled payment modules".

 

As a result of this, upon clicking the checkout button or link, the customer is taken directly to the checkout_confirmation page where product totals, billing information, and payment method are all displayed (how, you may ask? Magic as far as I can tell- but I know the payment page has already loaded the billing information by the time it gets to the IFD code and I've only enabled one payment method for this payment group, thanks to SPPC, and this gets loaded early on too).

 

It works!

That's some great work :) Next time I update the contribution I'll give a link to this post for anyone wanting a similar solution.

 

Thanks for sharing!

Link to comment
Share on other sites

Frankly, I am confused after reading this, but maybe it is because my application is really different.

I have no shipping charges.

We are using the latest osC build.

~~~

A. I need to sell only a SERVICE and I am a reseller of that service.

B. This is a Real Time Authorization and I must coordinate with the bank and a distant supplier using Secure Messaging.

C. The customer gets a 'user code' to use; within seconds of securely purchasing online

 

1. The bank will send me a 'secure message' confirming they have the customers money for me, safe! {using Verified by VISA, MasterCard SecureCode, 3-D Secure}

2. The bank's 'secure message' is also copied to my supplier at the same instant.

3. My supplier acccepts the bank's secure message as 'authentic' and confirming a guaranteed sale.

4. Then the supplier sends me a data message with a 'user code' for my customer.

5. I must take the data message and use it to generate an email to the customer (in his language)

6. and then I send an SMS to his mobile phone (also in his language) [ "SMS Me" - Order Updates by SMS, http://www.oscommerce.com/community/contri...rch,sms+gateway ]

 

So I need to have No Shipping Page, No Shipping Charges...

 

Who knows how to do some of this please?

Many, many, many, grateful thanks!!! ...

We are happy to share these Best Practices answers, of course!!!

Best Regards,

Charles

:rolleyes:

Link to comment
Share on other sites

Frankly, I am confused after reading this, but maybe it is because my application is really different.

I have no shipping charges.

We are using the latest osC build.

~~~

A. I need to sell only a SERVICE and I am a reseller of that service.

B. This is a Real Time Authorization and I must coordinate with the bank and a distant supplier using Secure Messaging.

C. The customer gets a 'user code' to use; within seconds of securely purchasing online

 

Well, if the virtual product portion of osCommerce works the way it should all you have to do is go to admin->configuration->download and set "enable download" to true. I'm not sure if you have to set the products at zero weight or what, but with that setting the osC cart is supposed to skip the shipping page.

 

That hasn't been my experience so I turned to Lane's Zero Weight Skips Shipping code.

 

If using the virtual product setting in your store's admin doesn't work then just install Zero Weight Skips Shipping as per the original instructions (you don't want to do all the stuff I did because I wanted to skip the payment page too) and you should be all set.

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

Yes, djmonkey1 in Detroit has the ANSWER!

Thank you!

Short sweet, & effective. No surprise, eh?

I made the basic changes you recommended and it worked the first time!

Then I went back to Shipping/Packaging and zeroed out the weights as a precaution because our system is very complicated and we need to protect against spurrious data being generated later by accident.

Finally we were left with the following:

Country of Origin Czech Republic

Postal Code NONE

Enter the Maximum Package Weight you will ship 0

Package Tare weight. 0 Info

Larger packages - percentage increase. 0

 

And it still works! ...'puuurrrrfectly' ......

Many thanks to djmonkey1!!!!

 

Best wishes,

Charles

B)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...