WC_Product $product, int $quantity): bool { if (!$this->cart) { throw new Exception('Cart not set.'); } $cart_item_key = $this->cart->add_to_cart($product->get_id(), $quantity); if ($cart_item_key) { $this->cart_item_keys[] = $cart_item_key; } return \false !== $cart_item_key; } /** * Adds variations to the cart. * * @param \WC_Product $product The Product. * @param int $quantity The Quantity. * @param array $post_variations The variations. * * @return bool * @throws Exception When product could not be added. */ public function add_variable_product(\WC_Product $product, int $quantity, array $post_variations): bool { if (!$this->cart) { throw new Exception('Cart not set.'); } $variations = array(); foreach ($post_variations as $key => $value) { $variations[$value['name']] = $value['value']; } $variation_id = $this->product_data_store->find_matching_product_variation($product, $variations); // ToDo: Check stock status for variation. $cart_item_key = $this->cart->add_to_cart($product->get_id(), $quantity, $variation_id, $variations); if ($cart_item_key) { $this->cart_item_keys[] = $cart_item_key; } return \false !== $cart_item_key; } /** * Adds booking to the cart. * * @param \WC_Product $product The Product. * @param array $data Data used by the booking plugin. * * @return bool * @throws Exception When product could not be added. */ public function add_booking_product(\WC_Product $product, array $data): bool { if (!$this->cart) { throw new Exception('Cart not set.'); } if (!is_callable('wc_bookings_get_posted_data')) { return \false; } $cart_item_data = array('booking' => wc_bookings_get_posted_data($data, $product)); $cart_item_key = $this->cart->add_to_cart($product->get_id(), 1, 0, array(), $cart_item_data); if ($cart_item_key) { $this->cart_item_keys[] = $cart_item_key; } return \false !== $cart_item_key; } /** * Removes stored cart items from WooCommerce cart. * * @return void * @throws Exception Throws if there's a failure removing the cart items. */ public function remove_cart_items(): void { if (!$this->cart) { throw new Exception('Cart not set.'); } foreach ($this->cart_item_keys as $cart_item_key) { if (!$cart_item_key) { continue; } $this->cart->remove_cart_item($cart_item_key); } } /** * Returns the cart item keys of the items added to cart. * * @return array */ public function cart_item_keys(): array { return $this->cart_item_keys; } }
Fatal error: Uncaught Error: Class "WooCommerce\PayPalCommerce\Button\Helper\CartProductsHelper" not found in /htdocs/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/services.php:207 Stack trace: #0 /htdocs/wp-content/plugins/woocommerce-paypal-payments/lib/packages/Inpsyde/Modularity/Container/ReadOnlyContainer.php(46): WooCommerce\PayPalCommerce\Button\ButtonModule::WooCommerce\PayPalCommerce\Button\{closure}(Object(WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Container\ReadOnlyContainer)) #1 /htdocs/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-applepay/services.php(114): WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Container\ReadOnlyContainer->get('button.helper.c...') #2 /htdocs/wp-content/plugins/woocommerce-paypal-payments/lib/packages/Inpsyde/Modularity/Container/ReadOnlyContainer.php(46): WooCommerce\PayPalCommerce\Applepay\ApplepayModule::WooCommerce\PayPalCommerce\Applepay\{closure}(Object(WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Container\ReadOnlyContainer)) #3 /htdocs/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-applepay/src/ApplepayModule.php(66): WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Container\ReadOnlyContainer->get('applepay.button') #4 /htdocs/wp-includes/class-wp-hook.php(341): WooCommerce\PayPalCommerce\Applepay\ApplepayModule::WooCommerce\PayPalCommerce\Applepay\{closure}('') #5 /htdocs/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters(NULL, Array) #6 /htdocs/wp-includes/plugin.php(522): WP_Hook->do_action(Array) #7 /htdocs/wp-settings.php(742): do_action('init') #8 /htdocs/wp-config.php(90): require_once('/htdocs/wp-sett...') #9 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #10 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #11 /htdocs/index.php(17): require('/htdocs/wp-blog...') #12 {main} thrown in /htdocs/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/services.php on line 207