I want to make a plugin to do something around a custom made checkout method. I do have other interceptors working prior to adding this, but this one I am getting a ltrim warning.

CRITICAL: Exception: Warning: ltrim() expects parameter 1 to be string, object given in /mnt/magento_prime/vendor/magento/framework/Code/Generator/EntityAbstract.php on line 152 in /mnt/magento_prime/vendor/magento/framework/App/ErrorHandler.php:61

I have no clue what should be causing this, and it is giving me a headache.



<type name="Vendor\Module\Model\Magento_Checkout\PaymentInformationManagement">
    <plugin name="Vendor_Module::Model_PaymentInformationManagement" type="Vendor\Module\Plugin\Vendor_Module\Model\PaymentInformationManagementPlugin" />

<!-- Snippit -->


namespace Vendor\Module\Plugin\Vendor_Module\Model;

class PaymentInformationManagementPlugin

    public function aroundSavePaymentInformationAndPlaceOrder(
        \Vendor\Module\Model\Magento_Checkout\PaymentInformationManagement $subject,
        \Closure $proceed,
        \Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
        \Magento\Quote\Api\Data\AddressInterface $billingAddress = null
        // run parent method and capture int $orderId
        $orderId = $proceed($cartId, $paymentMethod, $billingAddress);

        return $orderId;

I have looked at questions like:

Magento 2 Error occured after upgrade : Warning: ltrim() expects parameter 1 to be string, array given

But the solutions, like removing the var folders, do not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.