Shipping methods for certain products

Hi Folks

Is there a way to add a shipping method based on a product group or product attribute? I can only see an option for a shipping method depending on a user group.

I have made website in concrete 8.5.4 and I am using community Store 2.3.1.

Url for dev area is: https://ashers.aurora-studio-dev.co.uk

There are two options for shopping online - (Online Shop or Home Delivery)

Online shop is only for specific products that can be shipped using Royal Mail - Free Delivery

Home delivery is only for specific products and for people who live within a 3 mile radius of one of the local outlets as they will be using the bakeries own delivery van - £3.50 for delivery

I need to be able to apply a home delivery shipping method to home deliveries only and a free uk standard shipping to online shop orders only.

My issue is I cant seem to get the system to distinguish between a home delivery order or an online order.

p.s if you want to try adding products for home delivery just use IV23TQ as a postcode.

Cheers

Out of the box what you’ve described isn’t possible, as shipping methods just look at the totals for orders, and calculates rates accordingly.

But the idea is that you’d be able to achieve this by developing your own shipping methods, ones that can do whatever they need to (so look at groups or attributes), to work out rates, whether they are offered, etc.

Both the built in shipping methods are good examples, but there’s also:

And some doco here:
https://concrete5-community-store.github.io/community_store/developers/shipping_methods.html

What you’d be aiming to do is putting some logic in the isEligible function, which determines whether that shipping method can be offered with the current order items.

The logic challenge I see here though is what happens when someone puts both kinds of products into their cart? Does it just fall back to standard delivery?

Hi Mesuva thanks you very much for the info, I will have to read through it all and see what I can come up with. I had hoped I may be able to use product attributes and then check if those products were in the basket, if they were I could then apply the shipping method based on that. But it looks like its going to be a bit more complicated.

" The logic challenge I see here though is what happens when someone puts both kinds of products into their cart? Does it just fall back to standard delivery?"

I wondered if somehow I could use the: Prevent this item from being in the cart with other items check box but beyond that I wasnt sure myself.

If I can get this working maybe it would be a good inclusion for V9?

Within a custom shipping method you should be able to loop through products in the cart and then fetch their attributes to make decisions (I’ve done that myself).

The challenge with shipping in general is that everyone has their own requirements, and often the requirements are quite specific (but not unreasonable). So adding individual features into the core becomes pretty problematic to try to cover everyone’s needs.

Instead, that’s where being able to develop custom shipping methods fairly easily comes into play, and means you’ve got complete control, instead of having to wrangle built-in logic that doesn’t 100% fit your needs.

So if you do get this working, what is great is then making publicly available your custom shipping method, to act as another example or a base for someone else to customise.

In terms of restricting items in the cart, the check box that is available for that is not really intended for this kind of situation, it’s more for if you are selling something like a membership, and you only want that to go through by itself, and you don’t want someone being able to add multiple membership products together in the same cart.

What you may need to investigate is using events to keep an eye on the cart, and modify it when it detects two different product groups together, and does something to manage that.

It might be easier to customise the checkout page to detect that and put in some sort of message at the top, highlighting the products. That then would just require a single page template override.

Hi Mesuva

Sorry for the late repy, I was working on a different project last week so had my head deep in that.

This is great info thank you and it points me down the right direction. I am going to try getting this started this week, no promises on how long it will take or how many paracetamol I will need lol .

Thanks again

Hi Mesuva,

Just thought you might like to know that we have sorted the issue without making a new shipping method.

I managed to add some extra code into the isEligible() function on the Flat Rate and Free Shipping methods that come with community store, I looped through each item and checked which product group was in the basket which then applied the correct shipping.

We also managed (I had invaluable help from my work colleague) to loop through each item in the basket and then, by using the actions automatically remove the offending product and throw an error message.

All in all I couldn’t have completed this without you pointing me in the right direction. So thank you very much for the time you took to answer my problem.

Cheers Tim :grinning:

Ahh that’s great to hear!

Can I suggest though it’s probably worthwhile eventually turning this into it’s own shipping method - if you’ve edited Community Store’s files, you run the risk of overwriting the changes if you do a package update.

Yeah of course, its probably a good idea, they didnt seem to want to work out of the applications folder so will have to look at that.

Its all good practice!! :grinning: :wink:

sounds good thanks for information :+1: