| 1 |
<?php |
| 2 |
namespace YayMail\Elements; |
| 3 |
|
| 4 |
use YayMail\Abstracts\BaseElement; |
| 5 |
use YayMail\Utils\SingletonTrait; |
| 6 |
|
| 7 |
/** |
| 8 |
* Billing Address Elements |
| 9 |
*/ |
| 10 |
class BillingAddress extends BaseElement { |
| 11 |
|
| 12 |
use SingletonTrait; |
| 13 |
|
| 14 |
protected static $type = 'billing_address'; |
| 15 |
|
| 16 |
public $available_email_ids = [ YAYMAIL_WITH_ORDER_EMAILS ]; |
| 17 |
|
| 18 |
public static function get_data( $attributes = [] ) { |
| 19 |
$is_email_improvements_enabled = get_option( 'woocommerce_feature_email_improvements_enabled', 'no' ) === 'yes'; |
| 20 |
$layout_type = $is_email_improvements_enabled ? 'modern' : 'legacy'; |
| 21 |
|
| 22 |
self::$icon = '<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" viewBox="0 0 20 20"> |
| 23 |
<path d="M17.5,2.5v15H2.5V2.5h15M18.5,1H1.5c-.28,0-.5.22-.5.5v17c0,.28.22.5.5.5h17c.28,0,.5-.22.5-.5V1.5c0-.28-.22-.5-.5-.5h0Z"/> |
| 24 |
<path d="M6.79,7.33c.57,0,1.04.47,1.04,1.04s-.47,1.04-1.04,1.04-1.04-.47-1.04-1.04.47-1.04,1.04-1.04M6.79,5.83c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54,2.54-1.14,2.54-2.54-1.14-2.54-2.54-2.54h0Z"/> |
| 25 |
<path d="M10.75,13.46h-1.5c0-1.25-1.01-2.26-2.26-2.26s-2.26,1.01-2.26,2.26h-1.5c0-2.07,1.69-3.76,3.76-3.76s3.76,1.69,3.76,3.76Z"/> |
| 26 |
<rect x="12.24" y="7.5" width="2.94" height="1.5"/> |
| 27 |
<rect x="12.24" y="10.87" width="4.62" height="1.5"/> |
| 28 |
</svg>'; |
| 29 |
|
| 30 |
return [ |
| 31 |
'id' => uniqid(), |
| 32 |
'type' => self::$type, |
| 33 |
'name' => __( 'Billing Address', 'woocommerce' ), |
| 34 |
'icon' => self::$icon, |
| 35 |
'group' => 'woocommerce', |
| 36 |
'available' => true, |
| 37 |
'position' => 170, |
| 38 |
'data' => [ |
| 39 |
'container_group_definition' => [ |
| 40 |
'component' => 'GroupDefinition', |
| 41 |
'title' => __( 'Container settings', 'yaymail' ), |
| 42 |
'description' => __( 'Handle container layout settings', 'yaymail' ), |
| 43 |
], |
| 44 |
'padding' => ElementsHelper::get_spacing( $attributes ), |
| 45 |
'background_color' => ElementsHelper::get_color( $attributes, [ 'default_value' => '#fff' ] ), |
| 46 |
'content_breaker' => [ |
| 47 |
'component' => 'LineBreaker', |
| 48 |
], |
| 49 |
'content_group_definition' => [ |
| 50 |
'component' => 'GroupDefinition', |
| 51 |
'title' => __( 'Content settings', 'yaymail' ), |
| 52 |
'description' => __( 'Handle content settings', 'yaymail' ), |
| 53 |
], |
| 54 |
'layout_type' => [ |
| 55 |
'value_path' => 'layout_type', |
| 56 |
'component' => 'Selector', |
| 57 |
'title' => __( 'Layout type', 'yaymail' ), |
| 58 |
'default_value' => isset( $attributes['layout_type'] ) ? $attributes['layout_type'] : $layout_type, |
| 59 |
'options' => [ |
| 60 |
[ |
| 61 |
'label' => __( 'Legacy', 'yaymail' ), |
| 62 |
'value' => 'legacy', |
| 63 |
], |
| 64 |
[ |
| 65 |
'label' => __( 'Modern', 'yaymail' ), |
| 66 |
'value' => 'modern', |
| 67 |
], |
| 68 |
], |
| 69 |
'type' => 'content', |
| 70 |
], |
| 71 |
'title_color' => ElementsHelper::get_color( |
| 72 |
$attributes, |
| 73 |
[ |
| 74 |
'value_path' => 'title_color', |
| 75 |
'title' => __( 'Title color', 'yaymail' ), |
| 76 |
'default_value' => YAYMAIL_COLOR_WC_DEFAULT, |
| 77 |
] |
| 78 |
), |
| 79 |
|
| 80 |
'text_color' => ElementsHelper::get_color( |
| 81 |
$attributes, |
| 82 |
[ |
| 83 |
'value_path' => 'text_color', |
| 84 |
'title' => __( 'Text color', 'yaymail' ), |
| 85 |
'default_value' => YAYMAIL_COLOR_TEXT_DEFAULT, |
| 86 |
] |
| 87 |
), |
| 88 |
|
| 89 |
'border_color' => ElementsHelper::get_color( |
| 90 |
$attributes, |
| 91 |
[ |
| 92 |
'value_path' => 'border_color', |
| 93 |
'title' => __( 'Table border color', 'yaymail' ), |
| 94 |
'default_value' => YAYMAIL_COLOR_BORDER_DEFAULT, |
| 95 |
] |
| 96 |
), |
| 97 |
'font_family' => ElementsHelper::get_font_family_selector( $attributes ), |
| 98 |
'title' => ElementsHelper::get_rich_text( |
| 99 |
$attributes, |
| 100 |
[ |
| 101 |
'value_path' => 'title', |
| 102 |
'title' => __( 'Billing title', 'yaymail' ), |
| 103 |
'default_value' => '<span style="font-size: 20px;font-weight:600;">' . __( 'Billing Address', 'woocommerce' ) . '</span>', |
| 104 |
] |
| 105 |
), |
| 106 |
'rich_text' => [ |
| 107 |
'value_path' => 'rich_text', |
| 108 |
'component' => '', |
| 109 |
'title' => __( 'Content', 'yaymail' ), |
| 110 |
'default_value' => '[yaymail_billing_address]', |
| 111 |
'type' => 'content', |
| 112 |
], |
| 113 |
], |
| 114 |
]; |
| 115 |
} |
| 116 |
} |
| 117 |
|