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
4 months ago
PriceData.php
1 year ago
Product.php
4 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
4 months ago
ProductReviewAverageRatingValue.php
4 months ago
ProductReviewBreakdown.php
4 months ago
ProductReviewContent.php
4 months ago
ProductReviewList.php
2 months ago
ProductReviewRating.php
4 months ago
ProductReviewTotalRating.php
4 months ago
ProductReviews.php
4 months ago
Quantity.php
10 months ago
SaleBadge.php
1 year ago
SelectedPriceAdHocAmount.php
1 year ago
VariantPill.php
6 months ago
VariantPills.php
1 year ago
SelectedPriceAdHocAmount.php
99 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Integrations\Bricks\Elements; |
| 4 | |
| 5 | use SureCart\Integrations\Bricks\Concerns\ConvertsBlocks; |
| 6 | use SureCart\Support\Currency; |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; // Exit if accessed directly. |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Selected Price Ad Hoc Amount element. |
| 14 | */ |
| 15 | class SelectedPriceAdHocAmount extends \Bricks\Element { |
| 16 | use ConvertsBlocks; // we have to use a trait since we can't extend the surecart class. |
| 17 | |
| 18 | /** |
| 19 | * Element category. |
| 20 | * |
| 21 | * @var string |
| 22 | */ |
| 23 | public $category = 'SureCart Elements'; |
| 24 | |
| 25 | /** |
| 26 | * Element name. |
| 27 | * |
| 28 | * @var string |
| 29 | */ |
| 30 | public $name = 'surecart-product-selected-price-ad-hoc-amount'; |
| 31 | |
| 32 | /** |
| 33 | * Element block name. |
| 34 | * |
| 35 | * @var string |
| 36 | */ |
| 37 | public $block_name = 'surecart/product-selected-price-ad-hoc-amount'; |
| 38 | |
| 39 | /** |
| 40 | * Element icon. |
| 41 | * |
| 42 | * @var string |
| 43 | */ |
| 44 | public $icon = 'ion-md-create'; |
| 45 | |
| 46 | /** |
| 47 | * Get element label. |
| 48 | * |
| 49 | * @return string |
| 50 | */ |
| 51 | public function get_label() { |
| 52 | return esc_html__( 'Custom Amount', 'surecart' ); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Set controls. |
| 57 | * |
| 58 | * @return void |
| 59 | */ |
| 60 | public function set_controls() { |
| 61 | $this->controls['label'] = array( |
| 62 | 'label' => esc_html__( 'Label', 'surecart' ), |
| 63 | 'type' => 'text', |
| 64 | ); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Render element. |
| 69 | * |
| 70 | * @return void |
| 71 | */ |
| 72 | public function render() { |
| 73 | $label = ! empty( $this->settings['label'] ) ? $this->settings['label'] : esc_html__( 'Enter an amount', 'surecart' ); |
| 74 | |
| 75 | if ( $this->is_admin_editor() ) { |
| 76 | ob_start(); |
| 77 | ?> |
| 78 | <div class="wp-block-surecart-product-selected-price-ad-hoc-amount" data-sc-block-id="custom-amount"> |
| 79 | <label for="sc-product-custom-amount" class="sc-form-label"> |
| 80 | <?php echo wp_kses_post( $label ); ?> |
| 81 | </label> |
| 82 | <div class="sc-input-group"> |
| 83 | <span class="sc-input-group-text" id="basic-addon1"><?php echo esc_html( Currency::getCurrencySymbol() ); ?></span> |
| 84 | <input class="sc-form-control" id="sc-product-custom-amount" type="number" step="0.01"/> |
| 85 | </div> |
| 86 | </div> |
| 87 | <?php |
| 88 | $output = ob_get_clean(); |
| 89 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 90 | return; |
| 91 | } |
| 92 | echo $this->raw( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 93 | [ |
| 94 | 'label' => wp_kses_post( $label ), |
| 95 | ] |
| 96 | ); |
| 97 | } |
| 98 | } |
| 99 |