PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / Elementor / widgets / loop / discount / config.php
shop-press / Elementor / widgets / loop / discount Last commit date
config.php 2 years ago
config.php
98 lines
1 <?php
2 namespace ShopPress\Elementor\Widgets\LoopBuilder;
3
4 use Elementor\Controls_Manager;
5
6 use ShopPress\Elementor\ShopPressWidgets;
7
8 defined( 'ABSPATH' ) || exit;
9
10 class Discount extends ShopPressWidgets {
11
12 public function get_name() {
13 return 'sp-item-discount';
14 }
15
16 public function get_title() {
17 return __( 'Product Discount', 'shop-press' );
18 }
19
20 public function get_icon() {
21 return 'sp-widget sp-eicon-loop-product-discount';
22 }
23
24 public function get_categories() {
25 return array( 'sp_woo_loop' );
26 }
27
28 public function setup_styling_options() {
29
30 $this->register_group_styler(
31 'wrapper',
32 __( 'Wrapper', 'shop-press' ),
33 array(
34 'wrapper' => array(
35 'label' => esc_html__( 'Discount', 'shop-press' ),
36 'type' => 'styler',
37 'selector' => '.sp-product-discount',
38 ),
39 'label' => array(
40 'label' => esc_html__( 'Discount Label', 'shop-press' ),
41 'type' => 'styler',
42 'selector' => '.sp-product-discount .sp-product-discount-label',
43 ),
44 'price' => array(
45 'label' => esc_html__( 'Discount Price', 'shop-press' ),
46 'type' => 'styler',
47 'selector' => '.sp-product-discount .sp-product-discount-price',
48 ),
49 )
50 );
51 }
52
53 protected function register_controls() {
54 $this->start_controls_section(
55 'section_content',
56 array(
57 'label' => __( 'General', 'shop-press' ),
58 )
59 );
60
61 $this->add_control(
62 'label',
63 array(
64 'label' => __( 'Label', 'shop-press' ),
65 'type' => Controls_Manager::TEXT,
66 'default' => '',
67 )
68 );
69
70 $this->end_controls_section();
71 $this->setup_styling_options();
72
73 do_action( 'shoppress/elementor/widget/register_controls_init', $this );
74 }
75
76 protected function render() {
77 $settings = $this->get_settings_for_display();
78
79 do_action( 'shoppress/widget/before_render', $settings );
80
81 $args = array(
82 'label' => $settings['label'],
83 );
84
85 if ( $this->editor_preview() ) {
86 sp_load_builder_template( 'loop/loop-discount', $args );
87 }
88 }
89
90 protected function content_template() {
91 ?>
92 <div class="sp-product-discount">
93 <span class="sp-product-discount-label">{{{ settings.label }}}</span> <span class="sp-product-discount-price"> 10% </span>
94 </div>
95 <?php
96 }
97 }
98