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