| @@ -21,6 +21,17 @@ | ||
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | // Only create button if the product has woo-vipps express checkout enabled. LP 29.11.2024 |
| 24 | 24 | if ($supported) { |
| 25 | - echo "<div class='wp-block-button wc-block-components-product-button wc-block-button-vipps'>" . $vipps->get_buy_now_button_manual($product->get_id(), null, null, false, '', $block->attributes['variant'], $block->attributes['language']) . "</div>"; | |
| 25 | + // In retrospect, the web component button args should probably be in one attribute object instead, to avoid stuff like this. LP 2026-07-01 | |
| 26 | + $button_args = []; | |
| 27 | + foreach(['compact', 'rounded'] as $bool_attr) { | |
| 28 | + $button_args[$bool_attr] = ($block->attributes[$bool_attr] ?? false) ? 'true' : 'false'; | |
| 29 | + } | |
| 30 | + foreach(['verb', 'variant', 'language'] as $str_attr) { | |
| 31 | + $button_args[$str_attr] = $block->attributes[$str_attr] ?? ''; | |
| 32 | + } | |
| 33 | + // Looks like button and badge web components now use 'da' instead of 'dk' for danish. LP 2026-08-11 | |
| 34 | + if ('dk' === $button_args['language']) $button_args['language'] = 'da'; | |
| 35 | + | |
| 36 | + echo "<div class='wp-block-button wc-block-components-product-button wc-block-button-vipps'>" . $vipps->get_buy_now_button($product->get_id(), null, null, false, '', 'gutenberg', $button_args) . "</div>"; | |
| 26 | 37 | } |