Skip to content
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

Paypal checkout not possible with products that have custom options #5938

Closed
mktudock opened this issue Aug 2, 2016 · 15 comments
Closed

Paypal checkout not possible with products that have custom options #5938

mktudock opened this issue Aug 2, 2016 · 15 comments
Labels
bug report Component: Checkout Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@mktudock
Copy link

mktudock commented Aug 2, 2016

Preconditions

  1. Have Magento 2.1. (with PHP 7)
  2. Install the sample data and create a new store view
  3. Go to any (configurable) product and create a custom option as a dropdown with some options (for global)

Steps to reproduce

  1. Go to checkout with that product in cart, checkout with Amazon

Expected result

  1. The order gets created

Actual result

  1. An error message tells us that the order couldn't be created.

Due to a missing check in getOptionById of the Product model (removed in 0f00630), the product model tries to iterate over null when trying to create the order, because getOptions() returns null.

Seriously, how did you screw up custom options so badly in 2.1.? They are not functional at all!

@commcad
Copy link

commcad commented Aug 2, 2016

+1

Having the same issue here with 2.1.0GA.

  • Configurable product with swatches + any custom options as a dropdown
  • Paypal checkout > error order couldn't be created

Works fine for Simple product with the custom options only (no swatches). Custom options onto Configurable Products (with swatches) fails big time however. Unfortunate

Workaround "until a fix" is to kill the swatches and only use the custom options. Meaning you have to create an individual product for each configurations. That's a lot in our case :/

@mktudock
Copy link
Author

mktudock commented Aug 2, 2016

You can also install the following plugin, which restores the check:

namespace Vendor\Module\Plugin;

class ProductPlugin
{
    public function aroundGetOptionById(
        \Magento\Catalog\Model\Product $subject,
        callable $proceed,
        $option
    ) {
        if ($subject->getOptions() == null) {
            return null;
        }

        return $proceed($option);
    }
}

di.xml:

    <type name="Magento\Catalog\Model\Product">
        <plugin name="prevent-empty-array" type="Vendor\Module\Plugin\ProductPlugin" sortOrder="10"/>
    </type>

@commcad
Copy link

commcad commented Aug 2, 2016

Sweet man, I appreciate this.

Is this how you get around the custom options 'cannot create order' error?

Not at the shell PC atm but will be in a few hours. I'll give it a go.

@mktudock
Copy link
Author

mktudock commented Aug 3, 2016

@commcad Yes, after debugging we found out that was what caused the issue. In 2.0.7. the method worked differently and pretty much did what the plugin does now.

@commcad
Copy link

commcad commented Aug 3, 2016

too kind bud, sure many could do with a temp fix.

Silly question (to you); do we need to create a whole new custom module for this to work or it needs amending code somewhere. If so which *.php your code needs pasting into? Same question RE the di.xml - amending required? where

Sure a few others who will soon experience this bug will feel like asking, but won't dare lolll

@mktudock
Copy link
Author

mktudock commented Aug 3, 2016

Afaik you need to place this in a module (or the global shop di.xml).

The di.xml is placed in %module%/etc/di.xml and it's structure is described here http://devdocs.magento.com/guides/v2.0/extension-dev-guide/depend-inj.html

You can also use the global shop di.xml under %shop%/app/etc/di.xml, but you have to place the class I posted above somewhere where the shop can find it...

I didn't try it yet but you might want to try this if you don't want to use a new module:

  1. Insert the di.xml bit I posted above into %shop%/app/etc/di.xml - replace the plugin type with "Tudock\Plugins\Product"
  2. Create the folder app/code/Tudock/Plugins
  3. Place the class I posted above as Product.php in that folder
  4. Replace the namespace in that file with Tudock\Plugins
  5. Remove the var/di and var/generation folders
  6. Run bin/magento setup:di:compile

This might work if the autoloading finds the class. Otherwise it's propably easiest to create a new module.

@commcad
Copy link

commcad commented Aug 3, 2016

Quality Tweaks! Thanks for pointing us in the correct direction.

I-will-try. Need it badly as this bugs brings little over 100 more products to our catalog here :/ This invasion of thumbnails is terrifying our customer base I've recently heard lollll

Top man, thanks again

@duhon duhon assigned duhon and unassigned duhon Aug 5, 2016
@duhon
Copy link
Contributor

duhon commented Aug 9, 2016

@mktudock Thanks for reporting this issue.
We've created internal ticket MAGETWO-56695 to fix it.

@duhon duhon added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Aug 9, 2016
@Nerogee
Copy link

Nerogee commented Aug 10, 2016

+1 @mktudock

Seriously, how did you screw up custom options so badly in 2.1.? They are not functional at all!

@commcad
Copy link

commcad commented Sep 15, 2016

@duhon @mktudock

Was this bug fix abandoned? Any quick fix available in the meantime? We've failed implementing Mktudock custom module fix, hence why I ask.

Anyone have a link to MAGETWO-56695 so I can compare the code of 2.1.1 to the patched code? maybe this would work?

thanks

mmansoor-magento pushed a commit that referenced this issue Sep 20, 2016
mmansoor-magento pushed a commit that referenced this issue Sep 20, 2016
mmansoor-magento pushed a commit that referenced this issue Sep 20, 2016
Bug
MAGETWO-56699 [GITHUB] Paypal checkout not possible with products that have custom options #5938 - for mainline
MAGETWO-58290 [Github]Empty product option is added on each PUT request #5963
MAGETWO-58136 [Github] Shipping and billing address are not set if order placed with payment action Sale #6438
MAGETWO-55608 [GITHUB] M2.1: Not scrollable picture on mobile / product page #5302
MAGETWO-58285 Ajax error message doesn't display in backend
MAGETWO-58338 [Github]Problem adding attribute options that start with a number via REST Api #5715
MAGETWO-52575 Unable to apply free shipping to specified method when creating order in admin
MAGETWO-57078 [GITHUB] Can't set customer group when creating a new order in the admin. #6162
MAGETWO-58039 Table rate shipping not applying correctly - for mainline
@SerhiyShkolyarenko
Copy link
Contributor

@mktudock @commcad we delivered MAGETWO-56699 fix to develop branch. Thank you for cooperation.

@Ctucker9233
Copy link

@SerhiyShkolyarenko Will MAGETWO-56699 be included in 2.1.3?

@skiwithpete
Copy link

skiwithpete commented Jan 2, 2017

@mktudock
Using your instructions I get this error:

php bin/magento setup:di:compile
Compilation was started.
Proxies code generation... 0/7 [>---------------------------]   0% 1 sec 18.0 MiProxies code generation... 1/7 [====>-----------------------]  14% 1 sec 22.0 MiRepositories code generation... 1/7 [====>-----------------------]  14% 1 sec 22.0 MiB
Fatal error: Class 'Magento\Eav\Model\Entity\Attribute\Source\Boolean' not found in /home/oneupkey/public_html/vendor/magento/module-catalog/Model/Product/Attribute/Source/Boolean.php on line 14
Segmentation fault

@audexpro
Copy link

News on this issue?

@benyanke
Copy link

Any luck on this?

mmansoor-magento pushed a commit that referenced this issue Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Checkout Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests