Giter Site home page Giter Site logo

Comments (9)

boxblinkracer avatar boxblinkracer commented on August 17, 2024 1

Hi @snc
I wanted to reach out and let you know that the pull request has been merged.
The feature will be released with the next update

from shopware.

boxblinkracer avatar boxblinkracer commented on August 17, 2024

Hi there
thank you for letting us know.
ok that is...just weird...always all these plugins :D

anyway, doing our best to solve it,
thanks

from shopware.

boxblinkracer avatar boxblinkracer commented on August 17, 2024

Hi

I've just tested it, and it worked on my end.
can you output the json error that happens?
what is inside the ordermail variables? might be an invalid json

thank you

from shopware.

snc avatar snc commented on August 17, 2024

Hi,

I've continued to debug this issue on our side and found the cause of it. It already fails when encoding the JSON in

$transaction->setOrdermailVariables(json_encode($variables));
, so the value in the database is NULL.

I've checked json_last_error() and it returned 7 (JSON_ERROR_INF_OR_NAN).
After adding the JSON_PARTIAL_OUTPUT_ON_ERROR flag to the json_encode call it finally worked again:

$transaction->setOrdermailVariables(json_encode($variables, JSON_PARTIAL_OUTPUT_ON_ERROR));

Maybe the plugin could check if the call to json_encode failed, as no exception is thrown by default.

The part of the variables that is causing JSON_ERROR_INF_OR_NAN can be seen here:

...,"price":"15,71","pseudoprice":"20,95","referenceprice":"NaN","has_pseudoprice":true,"price_numeric":15.712499,...

Let's see if I can find out where the referenceprice is set to NaN...

from shopware.

boxblinkracer avatar boxblinkracer commented on August 17, 2024

ah perfect
yes, i would love to improve that in the plugin.
most of the time i try to do the fail-fast approach...otherwise you might not have discovered an invalid price in your json :)

but maybe i can switch over to a softer check and add a json parse log entry instead ;)

what do you think?

from shopware.

snc avatar snc commented on August 17, 2024

The following line from the Advanced Promotion Suite plugin is causing the NaN:

$product['additional_details']['referenceprice'] = $price / $purchaseUnit * $referenceUnit;

In our case, the $purchaseUnit and $referenceUnit is null.

I'm unsure about how you should handle NaN and/or Inf case, but you should definitely check if the json_encode result is null. Maybe using serialize and unserialize could be another solution, but this might not be backwards compatible.

from shopware.

boxblinkracer avatar boxblinkracer commented on August 17, 2024

Hi @snc

thank you for this.
i've created an improvement based on your input, worked great for me when producing a NaN value.

values will now be 0, which yeah...could be misleading in case its even displayed in the mail
but still better i think, because the main values should always be valid i think :)

in addition to this, warning logs are generated
let me know what you think

#297

from shopware.

snc avatar snc commented on August 17, 2024

Hi @boxblinkracer, the PR looks good to me! Thanks.

from shopware.

boxblinkracer avatar boxblinkracer commented on August 17, 2024

perfect, thanks @snc
always happy to help :)

from shopware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.