config.php
99 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 Price extends ShopPressWidgets { |
| 10 | |
| 11 | public function get_name() { |
| 12 | return 'sp-item-price'; |
| 13 | } |
| 14 | |
| 15 | public function get_title() { |
| 16 | return __( 'Product Price', 'shop-press' ); |
| 17 | } |
| 18 | |
| 19 | public function get_icon() { |
| 20 | return 'sp-widget sp-eicon-product-price'; |
| 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' => '.sp-product-price', |
| 37 | ), |
| 38 | ) |
| 39 | ); |
| 40 | |
| 41 | $this->register_group_styler( |
| 42 | 'price', |
| 43 | __( 'Price', 'shop-press' ), |
| 44 | array( |
| 45 | 'price_wrapper' => array( |
| 46 | 'label' => esc_html__( 'Wrapper', 'shop-press' ), |
| 47 | 'type' => 'styler', |
| 48 | 'selector' => '.price', |
| 49 | 'wrapper' => '{{WRAPPER}} .sp-product-price', |
| 50 | ), |
| 51 | 'price' => array( |
| 52 | 'label' => esc_html__( 'Regular Price', 'shop-press' ), |
| 53 | 'type' => 'styler', |
| 54 | 'selector' => 'del span.woocommerce-Price-amount.amount', |
| 55 | 'wrapper' => '{{WRAPPER}} .sp-product-price .price', |
| 56 | ), |
| 57 | 'sale_price' => array( |
| 58 | 'label' => esc_html__( 'Sale Price', 'shop-press' ), |
| 59 | 'type' => 'styler', |
| 60 | 'selector' => 'span.woocommerce-Price-amount.amount', |
| 61 | 'wrapper' => '{{WRAPPER}} .sp-product-price .price', |
| 62 | ), |
| 63 | 'symbol_price' => array( |
| 64 | 'label' => esc_html__( 'Symbol', 'shop-press' ), |
| 65 | 'type' => 'styler', |
| 66 | 'selector' => '.woocommerce-Price-currencySymbol', |
| 67 | 'wrapper' => '{{WRAPPER}} .sp-product-price .woocommerce-Price-amount.amount', |
| 68 | ), |
| 69 | ) |
| 70 | ); |
| 71 | } |
| 72 | |
| 73 | protected function register_controls() { |
| 74 | $this->setup_styling_options(); |
| 75 | |
| 76 | do_action( 'shoppress/elementor/widget/register_controls_init', $this ); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | protected function render() { |
| 81 | do_action( 'shoppress/widget/before_render', $this->get_settings_for_display() ); |
| 82 | |
| 83 | if ( $this->editor_preview() ) { |
| 84 | sp_load_builder_template( 'loop/loop-price' ); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | protected function content_template() { |
| 89 | $classes = apply_filters( 'woocommerce_product_price_class', 'price' ); |
| 90 | ?> |
| 91 | <div class="sp-product-price"> |
| 92 | <p class="<?php echo esc_attr( $classes ); ?>"> |
| 93 | <span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>20</span> |
| 94 | </p> |
| 95 | </div> |
| 96 | <?php |
| 97 | } |
| 98 | } |
| 99 |