Block.php
42 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCartBlocks\Blocks\Address; |
| 4 | |
| 5 | use SureCartBlocks\Blocks\BaseBlock; |
| 6 | |
| 7 | /** |
| 8 | * Address Block. |
| 9 | */ |
| 10 | class Block extends BaseBlock { |
| 11 | /** |
| 12 | * Render the block |
| 13 | * |
| 14 | * @param array $attributes Block attributes. |
| 15 | * @param string $content Post content. |
| 16 | * |
| 17 | * @return string |
| 18 | */ |
| 19 | public function render( $attributes, $content = '' ) { |
| 20 | $default_country = $attributes['default_country'] ?? \SureCart::account()->tax_protocol->address->country ?? \SureCart::account()->brand->address->country ?? null; |
| 21 | ob_start(); ?> |
| 22 | |
| 23 | <sc-order-shipping-address |
| 24 | label="<?php echo esc_attr( $attributes['label'] ); ?>" |
| 25 | <?php echo $attributes['full'] ? 'full' : null; ?> |
| 26 | <?php echo $attributes['show_name'] ? 'show-name' : null; ?> |
| 27 | required="<?php echo false === $attributes['required'] ? 'false' : 'true'; ?>" |
| 28 | default-country="<?php echo esc_attr( $default_country ); ?>" |
| 29 | name-placeholder="<?php echo esc_attr( $attributes['name_placeholder'] ); ?>" |
| 30 | country-placeholder="<?php echo esc_attr( $attributes['country_placeholder'] ); ?>" |
| 31 | city-placeholder="<?php echo esc_attr( $attributes['city_placeholder'] ); ?>" |
| 32 | line-1-placeholder="<?php echo esc_attr( $attributes['line_1_placeholder'] ); ?>" |
| 33 | line-2-placeholder="<?php echo esc_attr( $attributes['line_2_placeholder'] ); ?>" |
| 34 | postal-code-placeholder="<?php echo esc_attr( $attributes['postal_code_placeholder'] ); ?>" |
| 35 | state-placeholder="<?php echo esc_attr( $attributes['state_placeholder'] ); ?>" |
| 36 | ></sc-order-shipping-address> |
| 37 | |
| 38 | <?php |
| 39 | return ob_get_clean(); |
| 40 | } |
| 41 | } |
| 42 |