-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Migrate Shop parameters -> Order settings page #9007
Migrate Shop parameters -> Order settings page #9007
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some few details needs to be fixed/improved, but it's good already
src/Adapter/CMS/CMSDataProvider.php
Outdated
*/ | ||
class CMSDataProvider | ||
{ | ||
public function getCMSPages($languageId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you mind to add PHPDoc for newly created classes? 👍
{ | ||
$choices = []; | ||
|
||
foreach ($this->cmsDataProvider->getCMSPages($languageId) as $cms) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see this function moved in CmsDataProvider instead, so you can inject the array instead of the full CmsDataProvider (like we already do to inject the locales).
use Symfony\Component\Form\FormView; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this form type already exists... wdyt @Quetzacoalt91 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find anything similar to this type - money type only adds the currency sign next to the input. This new type is used for situations like these: https://prnt.sc/jbyc7w
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure we already have this input type in Product page, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mickaelandrieu yes I've seen this one, but it's just an extension to money type, it's extending my new type as well. It doesn't have the functionality to enter a text suffix right after the currency sign so that's why I've created a new type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok! fair enough then 👍
*/ | ||
private function applySuffix(&$value, $key, $suffix) | ||
{ | ||
if (strlen($value) > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need a $key
here? You don't use it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because of array_walk where this method is used, array walk passes the value as the third argument so I must define the second argument as well. I don't like it, but is it worth changing array_walk to something custom because of that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this explanation to PHPDoc please, this makes Codacy cry a river.
wdyt @PierreRambaud?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, just add the explanation to PHPDoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applySuffix have an extra parameter "key" which is not used.
Hello, @rokaszygmantas this needs a rebase. @PierreRambaud I chose you to fairly review work of @rokaszygmantas and @sarjon as I'm in holidays for 1 week! |
@@ -0,0 +1,21 @@ | |||
<?php |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
137d437
to
4b966c9
Compare
public: true | ||
arguments: | ||
- '@prestashop.adapter.data_provider.currency' | ||
- '@=service("prestashop.adapter.data_provider.cms").getCmsChoices()' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we need to pass the language id to the function here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the cms data provider internally uses CMS::listCms($idLang = null, $idBlock = false, $active = true),
it takes the default language if no argument is passed. In this case the default language should be used so there's no need to pass it as an argument
https://github.com/PrestaShop/PrestaShop/blob/develop/classes/CMS.php#L166
this PR is still work in progress - please don't merge it yet :) |
@rokaszygmantas what is missing here from a functional point of view? |
Gift options fieldset is still missing and also the links are still pointing to the legacy controller. I should finish it tomorrow :) |
handleTermsAndConditionsCmsSelect(isTosEnabled) { | ||
const tosCmsSelect = $('#form_general_tos_cms_id'); | ||
|
||
if (isTosEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can replace the whole function by:
$('#form_general_tos_cms_id').prop('disabled', !isTosEnabled);
@mickaelandrieu now all functionality of the legacy controller is migrated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comment
@@ -82,11 +91,19 @@ public function setData(array $data) | |||
$data['general']['tos_cms_id'] = 0; | |||
} | |||
|
|||
// If gift wrapping tax rules group was not submitted - reset it to 0 | |||
if (!$data['gift_options']['gift_wrapping_tax_rules_group']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i prefer a condition using isset or array_key_exists please : more explicit
{ | ||
$errors = []; | ||
$invalidFields = []; | ||
$purchaseMinimumValue = $data['general']['purchase_minimum_value']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add some controls on $data['general']
and $data['gift_options']
? wdyt @mickaelandrieu ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, if these 2 keys don't exist or are null what happens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyway, this can be validated by QA.
TranslatorInterface $translator, | ||
array $locales, | ||
CurrencyDataProvider $currencyDataProvider, | ||
$tosCmsChoices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- $tosCmsChoices
+ array $tosCmsChoices
TranslatorInterface $translator, | ||
array $locales, | ||
CurrencyDataProvider $currencyDataProvider, | ||
$taxChoices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- $taxChoices
+ array $taxChoices
Hello @rokaszygmantas When I click on the "order" link in the breadcrumb I have a 404 because it's the link of the legacy page Otherwise everything is good :) |
Oh yes you're right, so it's all good for me :) |
and ... merged! Good job @rokaszygmantas, and thanks everyone for reviews! |
Important guidelines
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)