PAYONE-GmbH / magento-2

PAYONE Payment Extension for Magento 2
28 stars 56 forks source link

Unclear logic with addtocart.shortcut.buttons #459

Closed clicks-kodet closed 2 years ago

clicks-kodet commented 2 years ago

According to: https://github.com/PAYONE-GmbH/magento-2/blob/d343e22cb6c8bd6b3db2bfc74ece52e6f6851356/Observer/AddPaypalExpressButtons.php#L71

the button will not be rendered in case there is already a block \Magento\Catalog\Block\ShortcutButtons with name addtocart.shortcut.buttons or addtocart.shortcut.buttons.additional in the current layout. Why?

The default template contains this block and that case the button would never be rendered. I'd completely understand if the if would be negated

if (!in_array($shortcutButtons->getNameInLayout(), ['addtocart.shortcut.buttons', 'addtocart.shortcut.buttons.additional'])) {

as in such case you couldn't render it into block which doesn't exist and you intend to use it.

Could you explain me the current logic behind the if statement?

janteuber commented 2 years ago

Hello @clicks-kodet ,

Thanks for your message.

I will contact the developer directly for this. As soon as I have new information I will share it here.

FatchipRobert commented 2 years ago

This is not how it works.

$shortcutButtons->getNameInLayout() returns which layout block is currently processed.

The mentioned if statement determines where the button should not be displayed. The "addtocart.shortcut.buttons" block is used on the product details page. The Payone PayPal Express button is not supposed to be shown there.

The module intends to show the button in the mini-basket and on the basket page, which works reliably.

Bildschirmfoto 2022-07-11 um 12 25 22 Bildschirmfoto 2022-07-11 um 12 33 29