Forums / Built-in Shipping and Payment Modules / Flat Rate Shipping for just one product

Flat Rate Shipping for just one product

Views: 1,163

Results 1 to 6 of 6
16 Dec 2024, 6:34 PM
#1
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Flat Rate Shipping for just one product

V 157.d

We have always charged shipping by weight, but we have just taken on a product that needs to have a flat rate for shipping. I'm sure that has been asked here before, but I'm not seeing any earlier questions, and I don't see how to set it up. Our only other option would be to add the shipping cost to the basic price and give it free shipping, and I'd rather not do that if I don't have to. I'm competing with several other companies who are charging flat rate shipping, and many people are going to only look as far as seeing that my basic price appears to be higher, and not realize it includes shipping. Help?

18 Dec 2024, 7:03 PM
#2
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Re: Flat Rate Shipping for just one product

Can anyone even help with the flat.php code? It seems fairly straightforward, but I'm not sure where to change it to exclude everything except certain product numbers. I don't mind if the other shipping methods show up for a flat rate item, as long as the flat rate doesn't show up for anything else.

18 Dec 2024, 11:36 PM
#3
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: Flat Rate Shipping for just one product

HeleneWallis:

Can anyone even help with the flat.php code? It seems fairly straightforward, but I'm not sure where to change it to exclude everything except certain product numbers. I don't mind if the other shipping methods show up for a flat rate item, as long as the flat rate doesn't show up for anything else.

nothing with coding is straight forward.

start with your requirements. you only want to offer flat rate shipping for this one item. what happens if there are 2 of them in the cart? do they get twice the flat rate? or just the single rate? if they get just the single rate, at what point does it go up? when they order 100?

now what happens if they have that item in their cart and other items that get charged by weight? how do you want to handle that?

ideally you want to code this using an observer. but in v157, the flat rate observer was not there. it does exist in v210.

so now do you want to just copy that single flat rate file over to your v157 install so that you can use the observer?

very few things are simple in coding when you take a close look at it.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

19 Dec 2024, 1:03 AM
#4
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Re: Flat Rate Shipping for just one product

I’ve already considered both the possibilities that you mentioned. Fortunately, neither of them is likely to occur more than very occasionally. We’ll eat the shipping cost if it happens in the customer’s favor and refund the extra if it happens in our favor (which is what we already do anyway).

I wrote software for dozens of different systems and languages for over 50 years. I know it can be complex. I have Lyme disease and my brain is slowly falling apart, or I wouldn’t have to ask for help. I will look at the observer file for v2.01 but I may still not be able to figure it out. Thank you for the suggestion.

19 Dec 2024, 2:17 AM
#5
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: Flat Rate Shipping for just one product

copy this file:

https://github.com/zencart/zencart/blob/v2.0.1/includes/modules/shipping/flat.php

to where it is supposed to go, replacing the existing file.

enable flat rate shipping and put the price that you want to offer.

create this file:

includes/classes/observers/auto.carlwhat_observer.php

and put this in there (replace 8754 with the product_id of the item you want to offer flat rate shipping):

<?php
    /*  portions copyright by... zen-cart.com
        developed and brought to you by proseLA
        https://mxworks.cc
    */

    if (!defined('IS_ADMIN_FLAG')) {
        die('Illegal Access');
    }
    class zcObserverCarlwhatObserver extends base
    {
        public function __construct()
        {
            $this->attach($this, [
                'NOTIFY_SHIPPING_FLAT_UPDATE_STATUS',
            ]);
        }

        public function updateNotifyShippingFlatUpdateStatus(&$class, $eventID, &$p1, &$p2)
        {
            if (!$_SESSION['cart']->in_cart('8754')) {
                $p2 = false;
            }
        }
    }

if that does not work, someone else can help you with troubleshooting.

good luck.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

19 Dec 2024, 1:24 PM
#6
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Re: Flat Rate Shipping for just one product

carlwhat:

copy this file:

https://github.com/zencart/zencart/blob/v2.0.1/includes/modules/shipping/flat.php

to where it is supposed to go, replacing the existing file.

enable flat rate shipping and put the price that you want to offer.

create this file:

includes/classes/observers/auto.carlwhat_observer.php

and put this in there (replace 8754 with the product_id of the item you want to offer flat rate shipping):

<?php /* portions copyright by... zen-cart.com developed and brought to you by proseLA https://mxworks.cc */ if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } class zcObserverCarlwhatObserver extends base { public function __construct() { $this->attach($this, [ 'NOTIFY_SHIPPING_FLAT_UPDATE_STATUS', ]); } public function updateNotifyShippingFlatUpdateStatus(&$class, $eventID, &$p1, &$p2) { if (!$_SESSION['cart']->in_cart('8754')) { $p2 = false; } } } ``` > > if that does not work, someone else can help you with troubleshooting. > > good luck. Wow, I was not looking for that level of help, just something to get me started. That is very much appreciated, and I will spend some time studying what it does. I can still figure out most things if I have something to work from.