concretecms-community-store / community_store

An open, free and community developed eCommerce system for Concrete CMS
https://concretecms-community-store.github.io/community_store/
MIT License
106 stars 66 forks source link

Address and Shipping #839

Open SB1955 opened 9 months ago

SB1955 commented 9 months ago

Bit of an issue for me. Would like to have a 'line break' after town and county. Have tried to find how the address is generated and modify without luck. See attached. Also ‘Shipping’ is set to ‘Free Shipping’ however I’m seeing ‘to be determined’ before I get to the complete page? Thanks for any help you can give. Address-source Shipping-1 Shipping-2 Shipping-3

Mesuva commented 9 months ago

The address formatting is quite deep in the codebase: https://github.com/concretecms-community-store/community_store/blob/a8dcad0f9d72a8054979fbd7f9572024a65b1582/src/CommunityStore/Customer/Customer.php#L237

I think the best thing to do there is make some sort of change to that function to allow more configurability, and we can then look to include that in a future release.

The reason is shows 'To be determined', is that at that point you haven't put in a shipping address, so it doesn't know at that point whether shipping is going to be free or not. It might be, based on how you've set it up, but you could also have it offer other calculated and complex methods. Is the issue that you just want it to always show free shipping, as that's the only shipping option you are ever going to set up?

SB1955 commented 9 months ago

Thanks for looking. What I can do as I have before is edit the 'checkout.php' file to show 'No Charge'.

SB1955 commented 9 months ago

There many ways to formatting an address. Have several letters with variants, for me I’ve added a break to lines 258 and 264 in the ‘Customer.php’ file.

Thanks for giving me the place to modify.

$line = $city; if ($stateProvince !== '') { if ($line !== '') { $line .= ', break'; } $line .= $app->make('helper/lists/states_provinces')->getStateProvinceName($stateProvince, $country) ?: $stateProvince; } if ($postalCode !== '') { if ($line !== '') { $line .= ', break'; }

Mesuva commented 9 months ago

I think I'm going to re-open this issue, as a reminder that it would be great to have a way to customise the output of the address format, through some sort of configuration.

SB1955 commented 9 months ago

Ok. Thanks. See screenshots for my mods.

One-AD Two-AD Three-AD Address-Mod

Mesuva commented 9 months ago

What I'm considering is using something like this library here: https://github.com/adamlc/address-format

mlocati commented 9 months ago

Can't we use commerceguys/addressing (already included in Concrete)?

Also, what about letting people customize the way we format addresses? In case you are interested, I can submit a pull request

Mesuva commented 9 months ago

I didn't realise Concrete already had a library - yep, that's much better than introducing something new.

It think if we have it formatting the address automatically, there would actually be very little need to be able to customise the address format. Every time someone has asked about it, it's to support a particular country's formatting.

But I'm thinking a customisation option doesn't actually make sense, as the address should be formatted as per the country selected in the address itself.

Mesuva commented 9 months ago

I've just made this change: https://github.com/concretecms-community-store/community_store/commit/7d119c112839dada9285c80996d4ebd5a443de98

This appears to work correctly on V8 and V9, and I think will cover pretty much everyone