• Resolved dchende

    (@dchende)


    Hi zusammen,

    habe einen Fehler in einem Shop mit Variationen.

    Hier der Fehler im Nginx-Log
    17628#0: *12891 FastCGI sent in stderr: "PHP message: parent was called incorrectly. Produkteigenschaften sollten nicht direkt abgerufen werden. Backtrace: do_action('wp_ajax_paypal_express_checkout_request'), WP_Hook->do_action, WP_Hook->apply_filters, WCPayPalPlus\ExpressCheckoutGateway\AjaxHandler->handle, WCPayPalPlus\ExpressCheckoutGateway\Dispatcher->dispatch, do_action('woopaypalplus.express_checkout_request/product/createOrder'), WP_Hook->do_action, WP_Hook->apply_filters, WCPayPalPlus\ExpressCheckoutGateway\SingleProductCheckout->createOrder, WCPayPalPlus\ExpressCheckoutGateway\CartCheckout->createOrder, WCPayPalPlus\Payment\PaymentCreator->create, WCPayPalPlus\Payment\PaymentCreator->payment, WCPayPalPlus\Payment\PaymentCreator->itemsList, WCPayPalPlus\Payment\CartData->itemsList, WCPayPalPlus\Payment\CartData->item, WCPayPalPlus\Payment\CartItemData->get_sku, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong. This message was added in version 3.0.PHP message: parent was called incorrectly. Produkteigenschaften sollten nicht direkt abgerufen werden.

    Laut Woocommerce soll man Properties ab v3.0 nur über ihre Getter/Setter nutzen (siehe Class WC_Abstract_Legacy_Product __get() ). Deshalb werfen sie eine Warning, die aber bei AJAX-Calls scheinbar zum Paypal-Abbruch führt.

    An zwei Stellen in eurem Plugin finde ich einen direkten Zugriff:
    1. Class OrderItemData
    2. Class CartItemData

    Beispiel mit Fix:

        public function get_sku()
        {
            $product = $this->data['data'];
            $sku = $product->get_sku();
            if ($product instanceof \WC_Product_Variation) {
                // $sku = $product->parent->get_sku();
                $variation = wc_get_product( $product->get_parent_id() ); 
                $sku = $variation->get_sku();
            }
    
            return $sku;
        }
    

    Beide Klassen so umgeschrieben und Paypal funktioniert sauber.
    Könnt ihr das mal prüfen, bitte?

    == Info ==
    Nginx
    PHP 7.4.12
    Ubuntu 18.04.2 LTS

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Abbruch bei Variationen’ is closed to new replies.