woocommerce / woocommerce-gateway-paypal-express-checkout

58 stars 65 forks source link

Avoid fatal error when line_item is not an instance of WC_Product #856

Closed mircobabini closed 3 years ago

mircobabini commented 3 years ago

Description

Sometimes plugins and snippets out there uses this code to add custom lines to the cart (not instance of WC_Product): WC()->cart->add_to_cart( array );

This is causing a fatal error on $product->get_sku().

Steps to test:

  1. For instance, install LMS Masterstudy (free plugin from WordPress.org)
  2. In options activate WC Checkout; then create a course and add it to the cart
  3. Just complete the checkout and boom! Fatal error instead of the thank you page.

Documentation

Changelog entry

Enter a summary of all changes on this Pull Request. This will appear in the changelog if accepted.

Closes nothing; issue not reported, preferred to send this pull request.

jorgeatorres commented 3 years ago

Closed in favor of #872.