| 1 |
<?php |
| 2 |
namespace YayMail\Elements; |
| 3 |
|
| 4 |
use YayMail\Abstracts\BaseElement; |
| 5 |
use YayMail\Utils\SingletonTrait; |
| 6 |
/** |
| 7 |
* Shipping Address Elements |
| 8 |
*/ |
| 9 |
class ShippingAddress extends BaseElement { |
| 10 |
|
| 11 |
use SingletonTrait; |
| 12 |
|
| 13 |
protected static $type = 'shipping_address'; |
| 14 |
|
| 15 |
public $available_email_ids = [ YAYMAIL_WITH_ORDER_EMAILS ]; |
| 16 |
|
| 17 |
public static function get_data( $attributes = [] ) { |
| 18 |
$is_email_improvements_enabled = get_option( 'woocommerce_feature_email_improvements_enabled', 'no' ) === 'yes'; |
| 19 |
$layout_type = $is_email_improvements_enabled ? 'modern' : 'legacy'; |
| 20 |
|
| 21 |
self::$icon = '<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" viewBox="0 0 20 20"> |
| 22 |
<path d="M7.35,13.86h5.3c.09,0,.16-.07.16-.16v-1.69c0-.09-.07-.16-.16-.16h-.8c-.09,0-.16.07-.16.16v.72h-3.37v-.72c0-.09-.07-.16-.16-.16h-.8c-.09,0-.16.07-.16.16v1.69c0,.09.07.16.16.16ZM14.18,11.39c0,.21.08.42.24.57.15.15.36.24.57.24s.42-.08.57-.24c.15-.15.24-.36.24-.57s-.08-.42-.24-.57c-.15-.15-.36-.24-.57-.24s-.42.08-.57.24c-.15.15-.24.36-.24.57ZM18.98,8.02l-.48-.83s-.06-.06-.1-.07c-.04-.01-.08,0-.12.02l-1.02.59-1.57-4.34c-.08-.26-.25-.49-.47-.65-.22-.16-.49-.25-.76-.25H5.77c-.7,0-1.32.45-1.53,1.11l-1.5,4.12-1.02-.59s-.08-.03-.12-.02c-.04.01-.08.04-.1.07l-.48.83c-.04.08-.02.17.06.22l1.21.71-.29.8c-.02.06-.04.13-.04.2v6.99c0,.32.24.57.53.57h1.36c.25,0,.46-.19.51-.45l.15-.76h10.96l.15.76c.05.26.27.45.51.45h1.36c.29,0,.53-.26.53-.57v-6.99c0-.07-.01-.14-.04-.2l-.29-.8,1.21-.71s.06-.06.07-.1c.01-.04,0-.08-.01-.12ZM16.59,10.1v4.76H3.41v-4.76l.31-.86h12.55l.31.86ZM5.6,4.1v-.03s.02-.03.02-.03c.02-.07.08-.11.15-.11h8.59l1.51,4.18H4.14l1.46-4.02ZM4.22,11.39c0,.21.08.42.24.57.15.15.36.24.57.24s.42-.08.57-.24c.15-.15.24-.36.24-.57s-.08-.42-.24-.57c-.15-.15-.36-.24-.57-.24s-.42.08-.57.24c-.15.15-.24.36-.24.57Z"/> |
| 23 |
</svg>'; |
| 24 |
|
| 25 |
return [ |
| 26 |
'id' => uniqid(), |
| 27 |
'type' => self::$type, |
| 28 |
'name' => __( 'Shipping Address', 'woocommerce' ), |
| 29 |
'icon' => self::$icon, |
| 30 |
'group' => 'woocommerce', |
| 31 |
'available' => true, |
| 32 |
'position' => 160, |
| 33 |
'data' => [ |
| 34 |
'container_group_definition' => [ |
| 35 |
'component' => 'GroupDefinition', |
| 36 |
'title' => __( 'Container settings', 'yaymail' ), |
| 37 |
'description' => __( 'Handle container layout settings', 'yaymail' ), |
| 38 |
], |
| 39 |
'padding' => [ |
| 40 |
'value_path' => 'padding', |
| 41 |
'component' => 'Spacing', |
| 42 |
'title' => __( 'Padding', 'yaymail' ), |
| 43 |
'default_value' => isset( $attributes['padding'] ) ? $attributes['padding'] : [ |
| 44 |
'top' => '15', |
| 45 |
'right' => '50', |
| 46 |
'bottom' => '15', |
| 47 |
'left' => '50', |
| 48 |
], |
| 49 |
'type' => 'style', |
| 50 |
], |
| 51 |
'background_color' => [ |
| 52 |
'value_path' => 'background_color', |
| 53 |
'component' => 'Color', |
| 54 |
'title' => __( 'Background color', 'yaymail' ), |
| 55 |
'default_value' => isset( $attributes['background_color'] ) ? $attributes['background_color'] : '#fff', |
| 56 |
'type' => 'style', |
| 57 |
], |
| 58 |
'content_breaker' => [ |
| 59 |
'component' => 'LineBreaker', |
| 60 |
], |
| 61 |
'content_group_definition' => [ |
| 62 |
'component' => 'GroupDefinition', |
| 63 |
'title' => __( 'Content settings', 'yaymail' ), |
| 64 |
'description' => __( 'Handle content settings', 'yaymail' ), |
| 65 |
], |
| 66 |
'layout_type' => [ |
| 67 |
'value_path' => 'layout_type', |
| 68 |
'component' => 'Selector', |
| 69 |
'title' => __( 'Layout type', 'yaymail' ), |
| 70 |
'default_value' => isset( $attributes['layout_type'] ) ? $attributes['layout_type'] : $layout_type, |
| 71 |
'options' => [ |
| 72 |
[ |
| 73 |
'label' => __( 'Legacy', 'yaymail' ), |
| 74 |
'value' => 'legacy', |
| 75 |
], |
| 76 |
[ |
| 77 |
'label' => __( 'Modern', 'yaymail' ), |
| 78 |
'value' => 'modern', |
| 79 |
], |
| 80 |
], |
| 81 |
'type' => 'content', |
| 82 |
], |
| 83 |
'title_color' => [ |
| 84 |
'value_path' => 'title_color', |
| 85 |
'component' => 'Color', |
| 86 |
'title' => __( 'Title color', 'yaymail' ), |
| 87 |
'default_value' => isset( $attributes['title_color'] ) ? $attributes['title_color'] : YAYMAIL_COLOR_WC_DEFAULT, |
| 88 |
'type' => 'style', |
| 89 |
], |
| 90 |
'text_color' => [ |
| 91 |
'value_path' => 'text_color', |
| 92 |
'component' => 'Color', |
| 93 |
'title' => __( 'Text color', 'yaymail' ), |
| 94 |
'default_value' => isset( $attributes['text_color'] ) ? $attributes['text_color'] : YAYMAIL_COLOR_TEXT_DEFAULT, |
| 95 |
'type' => 'style', |
| 96 |
], |
| 97 |
'border_color' => [ |
| 98 |
'value_path' => 'border_color', |
| 99 |
'component' => 'Color', |
| 100 |
'title' => __( 'Table border color', 'yaymail' ), |
| 101 |
'default_value' => isset( $attributes['border_color'] ) ? $attributes['border_color'] : YAYMAIL_COLOR_BORDER_DEFAULT, |
| 102 |
'type' => 'style', |
| 103 |
], |
| 104 |
'font_family' => [ |
| 105 |
'value_path' => 'font_family', |
| 106 |
'component' => 'FontFamilySelector', |
| 107 |
'title' => __( 'Font family', 'yaymail' ), |
| 108 |
'default_value' => isset( $attributes['font_family'] ) ? $attributes['font_family'] : YAYMAIL_DEFAULT_FAMILY, |
| 109 |
'type' => 'style', |
| 110 |
], |
| 111 |
'title' => [ |
| 112 |
'value_path' => 'title', |
| 113 |
'component' => 'RichTextEditor', |
| 114 |
'title' => __( 'Shipping title', 'yaymail' ), |
| 115 |
'default_value' => isset( $attributes['title'] ) ? $attributes['title'] : ( '<span style="font-size: 20px;font-weight:600;">' . __( 'Shipping Address', 'woocommerce' ) . '</span>' ), |
| 116 |
'type' => 'content', |
| 117 |
], |
| 118 |
'rich_text' => [ |
| 119 |
'value_path' => 'rich_text', |
| 120 |
'component' => '', |
| 121 |
'title' => __( 'Content', 'yaymail' ), |
| 122 |
'default_value' => '[yaymail_shipping_address]', |
| 123 |
'type' => 'content', |
| 124 |
], |
| 125 |
], |
| 126 |
]; |
| 127 |
} |
| 128 |
} |
| 129 |
|