Skip to content

Update Supplier.php #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed

Update Supplier.php #242

wants to merge 4 commits into from

Conversation

switch-cheehau
Copy link

@switch-cheehau switch-cheehau commented Jul 9, 2021

add supplier.addressformat as configuration

refer to #239
Sorry, i've screwed up the commits in previous PR. re-create this PR for clean code.

add supplier.addressformat as configuration
@coveralls
Copy link

coveralls commented Jul 9, 2021

Coverage Status

Coverage decreased (-2.3%) to 86.296% when pulling 5997c7a on cgcomputers:make-supplier-address-format-configurable into ebf17e5 on aimeos:master.

@switch-cheehau switch-cheehau marked this pull request as ready for review July 9, 2021 06:30
@@ -179,7 +191,7 @@ public function setConfigFE( \Aimeos\MShop\Order\Item\Base\Service\Iface $orderS
if( ( $code = $attributes['supplier.code'] ) != '' )
{
// add short address as attribute for summary page / customer email
$attributes['supplier.address'] = $this->feConfig['supplier.code']['short'][$code];
$attributes['supplier.address'] = $this->feConfig['supplier.code'][$this->getConfigValue('supplier.addressformat')][$code];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use a default value if it's not set like:

$format = $this->getConfigValue( 'supplier.addressformat', 'short' );
$attributes['supplier.address'] = $this->feConfig['supplier.code'][$format][$code];

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can i do it in oneline?

$attributes['supplier.address'] = $this->feConfig['supplier.code'][$this->getConfigValue('supplier.addressformat','short')][$code];

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but the line will be very long and we try to keep the line length below 120 chars.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, okay, understand, i'll change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@aimeos
Copy link
Owner

aimeos commented Jul 14, 2021

We've discussed this a bit internally and came to the conclusion that adding just another format may not fit the requirements of many users as they may have different wishes for the address format depending on the country and/or intended use.

Our recommendation would be to add the format string directly to the configuration instead of a fixed list of format options.

@switch-cheehau
Copy link
Author

We've discussed this a bit internally and came to the conclusion that adding just another format may not fit the requirements of many users as they may have different wishes for the address format depending on the country and/or intended use.

Our recommendation would be to add the format string directly to the configuration instead of a fixed list of format options.

make sense.
If you need my help to continue the PR,
do you have any existing example that i can refer to implement the changes?

@aimeos
Copy link
Owner

aimeos commented Jul 14, 2021

Yes, your help would be valuable :-)
The solution is to use that string from provider configuration: https://github.com/aimeos/aimeos-core/blob/master/lib/mshoplib/src/MShop/Service/Provider/Decorator/Supplier.php#L72-L82

@switch-cheehau
Copy link
Author

create new PR for different approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants