cart icon indicating copy to clipboard operation
cart copied to clipboard

Error when no shippingAddress is set

Open darthnorman opened this issue 3 years ago • 3 comments

This line seems to always fail, resulting in an error (Call to a member function setPid() on bool in line 156) when there is no shipping address:

https://github.com/extcode/cart/blob/8c9c6ea6079d7d892811c1c9b59d754624289e73/Classes/Controller/Cart/OrderController.php#L152

$orderItem->isShippingSameAsBilling() returns nothing, I had to change it to $this->cart->isShippingSameAsBilling() to make it work, don't know if this is the correct way to fix it, tho.

darthnorman avatar Dec 13 '22 16:12 darthnorman

I had to make a bugfix release for this checkbox. Have you had a look at the documentation https://docs.typo3.org/p/extcode/cart/8.6/en-us/Changelog/8.5/Important-404-ChangeCheckboxValueInOrderForm.html?

Please compare the changes in https://github.com/extcode/cart/commit/f7d8505cccd79155370456ef94a3456f9ed602d8#diff-c7948006e90e97ea1ebe377bc61a15963136daf68d8cb4b6e998f8f9f8009af6L20 with the OrderForm.html used in the project.

Does this fix the problem? Otherwise, can you provide me with more information? Which version are you using? ...

extcode avatar Feb 03 '23 15:02 extcode

Hi,

exactly same problem here, but I think I spotted it.

With settings.showCartAction.showPartials.shippingAddressForm = false the checkbox is not rendered at all due to the condition some lines above the checkbox:

https://github.com/extcode/cart/blob/f7d8505cccd79155370456ef94a3456f9ed602d8/Resources/Private/Partials/Cart/OrderForm.html#L14

thus $orderItem->isShippingSameAsBilling() in

https://github.com/extcode/cart/blob/8c9c6ea6079d7d892811c1c9b59d754624289e73/Classes/Controller/Cart/OrderController.php#L152

is false and the condition jumps to

https://github.com/extcode/cart/blob/8c9c6ea6079d7d892811c1c9b59d754624289e73/Classes/Controller/Cart/OrderController.php#L156

and fails on an empty $shippingAddress because it doesn't seem to get a value other than null in

https://github.com/extcode/cart/blob/8c9c6ea6079d7d892811c1c9b59d754624289e73/Classes/Controller/Cart/OrderController.php#L123

Workaround is to patch the createAction or place the checkbox outside the mentioned condition and make it a hidden field with value 1.

Hope that helps!?

TYPO3 10.4.37 cart 8.6.1 cart_products 4.1.0

h-e-l-l-o-w-o-r-l-d avatar Apr 17 '23 15:04 h-e-l-l-o-w-o-r-l-d

Same error here. Shipping and billing address are the same, checkbox is checked, error occurs. Editing the partial did not help.

UPDATE: I missed the new spelling of shipping_same_as_billing => shippingSameAsBilling in the partial. Now it works.

simare avatar May 09 '23 14:05 simare

@extcode The error does not occur longer as it seems, the author gave no further feedback and other confirmed that it works. Can be closed in my opinion.

rintisch avatar Mar 20 '24 19:03 rintisch