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
SaleBadge.php
88 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 | * Sale Badge element. |
| 14 | */ |
| 15 | class SaleBadge 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-sale-badge'; |
| 31 | |
| 32 | /** |
| 33 | * Element block name. |
| 34 | * |
| 35 | * @var string |
| 36 | */ |
| 37 | public $block_name = 'surecart/product-sale-badge'; |
| 38 | |
| 39 | /** |
| 40 | * Element icon |
| 41 | * |
| 42 | * @var string |
| 43 | */ |
| 44 | public $icon = 'ion-md-ribbon'; |
| 45 | |
| 46 | /** |
| 47 | * Get element label |
| 48 | * |
| 49 | * @return string |
| 50 | */ |
| 51 | public function get_label() { |
| 52 | return esc_html__( 'Sale Badge', 'surecart' ); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Set controls. |
| 57 | * |
| 58 | * @return void |
| 59 | */ |
| 60 | public function set_controls() { |
| 61 | $this->controls['text'] = array( |
| 62 | 'label' => esc_html__( 'Text', 'surecart' ), |
| 63 | 'type' => 'text', |
| 64 | ); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Render element. |
| 69 | */ |
| 70 | public function render() { |
| 71 | $text = ! empty( $this->settings['text'] ) ? $this->settings['text'] : esc_html__( 'Sale', 'surecart' ); |
| 72 | |
| 73 | if ( $this->is_admin_editor() ) { |
| 74 | echo $this->preview( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 75 | esc_attr( $text ), |
| 76 | 'sc-tag sc-tag--primary', |
| 77 | ); |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | echo $this->raw( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 82 | array( |
| 83 | 'text' => esc_attr( $text ), |
| 84 | ) |
| 85 | ); |
| 86 | } |
| 87 | } |
| 88 |