Shipping by Affiliate Link

Hi Guys! I was wondering if there is a way to allow shipping options by Affiliate Link/ID. I have a client using the app for fundraising and some fundraisers want to allow both flat rate shipping and local delivery, while others only want to allow flat rate shipping.

I know there are shipping plugins that can allow shipping methods based on user role, but in this case, the shopper is always a guest and the rule needs to be based on the Affiliate Link or ID being used.

If you don’t have an app that does this, are there a few lines of code that could be added to the php file where something like this happens? For example, if the default is to show both flat rate shipping and local delivery:

If Affiliate_ID=1, 13, 15, 22 Then hide Local Delivery?

This way, if an order comes in direct (1), the buyer would only have the option to ship via Flat Rate Shipping.

Thanks!
-Erica


Comments

3 responses to “Shipping by Affiliate Link”

  1. You’re welcome Erica, wish you too a great day and good luck with this implementation!

    Cheers

  2. Erica Thumma Avatar
    Erica Thumma

    Thanks, George! I appreciate you sharing this information! Have a great day.

  3. Hi Erica,

    Welcome back to our support channel.

    I’m afraid that something related doesn’t exist and you need to create a custom plugin for that purpose.
    The whole plugin consists of two parts and while the first one is pretty simple, the second one can be tricky.

    First you need to get the referring affiliate id with:
    $affiliate_id = Affiliates_Service::get_referrer_id();

    Then you need to check that id and accordingly adjust the shipping methods available. For the second part you should check the following examples which are provided by WC and can be found here:
    https://woocommerce.com/document/hide-other-shipping-methods-when-free-shipping-is-available/

    They are not offering exactly what you’re looking for but you can use the same logic and add the conditional check for the referring affiliate id.

    Kind regards,
    George

Share