BuyButton.php
1 year ago
CollectionTag.php
1 year ago
CollectionTags.php
1 year ago
Media.php
1 year ago
PriceChoiceTemplate.php
1 year ago
PriceChooser.php
1 year ago
PriceData.php
1 year ago
Product.php
1 year ago
ProductCard.php
1 year ago
ProductData.php
1 year ago
Quantity.php
1 year ago
SaleBadge.php
1 year ago
SelectedPriceAdHocAmount.php
1 year ago
VariantPill.php
1 year ago
VariantPills.php
1 year ago
PriceChoiceTemplate.php
152 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace SureCart\Integrations\Bricks\Elements; |
| 5 | |
| 6 | use SureCart\Integrations\Bricks\Concerns\ConvertsBlocks; |
| 7 | use SureCart\Integrations\Bricks\Concerns\NestableBlockChildren; |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; // Exit if accessed directly. |
| 11 | } |
| 12 | |
| 13 | /** |
| 14 | * Price Choice Template element. |
| 15 | */ |
| 16 | class PriceChoiceTemplate extends \Bricks\Element { |
| 17 | use ConvertsBlocks; // we have to use a trait since we can't extend the surecart class. |
| 18 | |
| 19 | /** |
| 20 | * Element name. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | public $name = 'surecart-product-price-choice-template'; |
| 25 | |
| 26 | /** |
| 27 | * Element block name. |
| 28 | * |
| 29 | * @var string |
| 30 | */ |
| 31 | public $block_name = 'surecart/product-price-choice-template'; |
| 32 | |
| 33 | /** |
| 34 | * Element icon. |
| 35 | * |
| 36 | * @var string |
| 37 | */ |
| 38 | public $icon = 'fas fa-money-bill-1'; |
| 39 | |
| 40 | /** |
| 41 | * This is nestable. |
| 42 | * |
| 43 | * @var bool |
| 44 | */ |
| 45 | public $nestable = true; |
| 46 | |
| 47 | /** |
| 48 | * Constructor. |
| 49 | * |
| 50 | * @param array $element Element. |
| 51 | * |
| 52 | * @return void |
| 53 | */ |
| 54 | public function __construct( $element = null ) { |
| 55 | $element['settings']['_gap'] = '0'; |
| 56 | parent::__construct( $element ); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Get element label. |
| 61 | * |
| 62 | * @return string |
| 63 | */ |
| 64 | public function get_label() { |
| 65 | return esc_html__( 'Price Choice', 'surecart' ); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Set controls. |
| 70 | * |
| 71 | * @return void |
| 72 | */ |
| 73 | public function set_controls() { |
| 74 | $this->controls['highlight_border'] = array( |
| 75 | 'label' => esc_html__( 'Highlight Border', 'surecart' ), |
| 76 | 'type' => 'color', |
| 77 | ); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Get nestable children. |
| 82 | * |
| 83 | * @return array |
| 84 | */ |
| 85 | public function get_nestable_children() { |
| 86 | return array( |
| 87 | array( |
| 88 | 'name' => 'surecart-price-data', |
| 89 | 'label' => esc_html__( 'Name', 'surecart' ), |
| 90 | 'settings' => array( |
| 91 | 'direction' => 'column', |
| 92 | 'alignItems' => 'flex-start', |
| 93 | '_justifyContent' => 'center', |
| 94 | '_width' => '50%', |
| 95 | '_flexBasis' => '50%', |
| 96 | 'meta' => [ |
| 97 | [ |
| 98 | 'dynamicData' => '{sc_price_name}', |
| 99 | ], |
| 100 | ], |
| 101 | ), |
| 102 | ), |
| 103 | array( |
| 104 | 'name' => 'surecart-price-data', |
| 105 | 'label' => esc_html__( 'Details', 'surecart' ), |
| 106 | 'settings' => array( |
| 107 | 'direction' => 'column', |
| 108 | 'alignItems' => 'flex-end', |
| 109 | '_justifyContent' => 'center', |
| 110 | '_width' => '50%', |
| 111 | '_flexBasis' => '50%', |
| 112 | '_gap' => '0', |
| 113 | '_lineHeight' => '1', |
| 114 | 'meta' => [ |
| 115 | [ |
| 116 | 'dynamicData' => '{sc_price_amount}', |
| 117 | ], |
| 118 | [ |
| 119 | 'dynamicData' => '{sc_price_trial}', |
| 120 | ], |
| 121 | [ |
| 122 | 'dynamicData' => '{sc_price_setup_fee}', |
| 123 | ], |
| 124 | ], |
| 125 | ), |
| 126 | ), |
| 127 | ); |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Render element. |
| 132 | * |
| 133 | * @return void |
| 134 | */ |
| 135 | public function render() { |
| 136 | if ( $this->is_admin_editor() ) { |
| 137 | echo $this->preview( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 138 | \Bricks\Frontend::render_children( $this ), |
| 139 | 'sc-choice' |
| 140 | ); |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | echo $this->raw( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 145 | [ |
| 146 | 'highlight_border' => esc_html( $this->get_raw_color( 'highlight_border' ) ), |
| 147 | ], |
| 148 | \Bricks\Frontend::render_children( $this ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 149 | ); |
| 150 | } |
| 151 | } |
| 152 |