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