start_controls_section( 'section_product', [ 'label' => __( 'Product', 'admore-widgets-suite' ), ] ); $this->add_control( 'product_source', [ 'label' => __( 'Product Source', 'admore-widgets-suite' ), 'type' => Controls_Manager::SELECT, 'default' => 'current', 'options' => [ 'current' => __( 'Current Post / Product', 'admore-widgets-suite' ), 'manual' => __( 'Choose by ID', 'admore-widgets-suite' ), ], ] ); $this->add_control( 'product_id', [ 'label' => __( 'Product ID', 'admore-widgets-suite' ), 'type' => Controls_Manager::NUMBER, 'default' => '', 'description' => __( 'Enter the WooCommerce Product ID.', 'admore-widgets-suite' ), 'condition' => [ 'product_source' => 'manual' ], ] ); $this->add_control( 'button_text', [ 'label' => __( 'Button Text', 'admore-widgets-suite' ), 'type' => Controls_Manager::TEXT, 'default' => '', 'placeholder' => __( 'Add to Cart', 'admore-widgets-suite' ), 'description' => __( 'Leave empty to use WooCommerce default text.', 'admore-widgets-suite' ), ] ); $this->add_control( 'show_quantity', [ 'label' => __( 'Show Quantity Input', 'admore-widgets-suite' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'return_value' => 'yes', ] ); $this->add_control( 'alignment', [ 'label' => __( 'Alignment', 'admore-widgets-suite' ), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'flex-start' => [ 'title' => __( 'Left', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-left' ], 'center' => [ 'title' => __( 'Center', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-center' ], 'flex-end' => [ 'title' => __( 'Right', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-right' ], ], 'default' => 'flex-start', 'selectors' => [ '{{WRAPPER}} .eppro-wac-form' => 'justify-content: {{VALUE}};' ], ] ); $this->end_controls_section(); // ── STYLE: Button ─────────────────────────────────────────────────── $this->start_controls_section( 'style_button', [ 'label' => __( 'Button', 'admore-widgets-suite' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->start_controls_tabs( 'btn_tabs' ); $this->start_controls_tab( 'btn_normal', [ 'label' => __( 'Normal', 'admore-widgets-suite' ) ] ); $this->add_control( 'btn_bg', [ 'label' => __( 'Background', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'default' => '#7c3aed', 'selectors' => [ '{{WRAPPER}} .eppro-wac-btn' => 'background-color: {{VALUE}};', ], ] ); $this->add_control( 'btn_color', [ 'label' => __( 'Text Color', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => [ '{{WRAPPER}} .eppro-wac-btn' => 'color: {{VALUE}};' ], ] ); $this->end_controls_tab(); $this->start_controls_tab( 'btn_hover', [ 'label' => __( 'Hover', 'admore-widgets-suite' ) ] ); $this->add_control( 'btn_hover_bg', [ 'label' => __( 'Background', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'default' => '#6d28d9', 'selectors' => [ '{{WRAPPER}} .eppro-wac-btn:hover' => 'background-color: {{VALUE}};' ], ] ); $this->add_control( 'btn_hover_color', [ 'label' => __( 'Text Color', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-wac-btn:hover' => 'color: {{VALUE}};' ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'btn_typography', 'selector' => '{{WRAPPER}} .eppro-wac-btn', 'separator' => 'before', ] ); $this->add_responsive_control( 'btn_padding', [ 'label' => __( 'Padding', 'admore-widgets-suite' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em' ], 'default' => [ 'top' => '12', 'right' => '28', 'bottom' => '12', 'left' => '28', 'unit' => 'px', 'isLinked' => false ], 'selectors' => [ '{{WRAPPER}} .eppro-wac-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); $this->add_control( 'btn_radius', [ 'label' => __( 'Border Radius', 'admore-widgets-suite' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'default' => [ 'size' => 6 ], 'selectors' => [ '{{WRAPPER}} .eppro-wac-btn' => 'border-radius: {{SIZE}}{{UNIT}};' ], ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'btn_border', 'selector' => '{{WRAPPER}} .eppro-wac-btn', ] ); $this->end_controls_section(); // ── STYLE: Quantity ───────────────────────────────────────────────── $this->start_controls_section( 'style_quantity', [ 'label' => __( 'Quantity', 'admore-widgets-suite' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'show_quantity' => 'yes' ], ] ); $this->add_control( 'qty_color', [ 'label' => __( 'Text Color', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-wac-wrap .qty' => 'color: {{VALUE}};' ], ] ); $this->add_control( 'qty_bg', [ 'label' => __( 'Background', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-wac-wrap .qty' => 'background-color: {{VALUE}};' ], ] ); $this->add_control( 'qty_width', [ 'label' => __( 'Width', 'admore-widgets-suite' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 40, 'max' => 200 ] ], 'default' => [ 'size' => 70 ], 'selectors' => [ '{{WRAPPER}} .eppro-wac-wrap .qty' => 'width: {{SIZE}}{{UNIT}};' ], ] ); $this->add_control( 'qty_radius', [ 'label' => __( 'Border Radius', 'admore-widgets-suite' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'default' => [ 'size' => 6 ], 'selectors' => [ '{{WRAPPER}} .eppro-wac-wrap .qty' => 'border-radius: {{SIZE}}{{UNIT}};' ], ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'qty_border', 'selector' => '{{WRAPPER}} .eppro-wac-wrap .qty', ] ); $this->end_controls_section(); } protected function render(): void { if ( ! class_exists( 'WooCommerce' ) ) { if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) { echo '

' . esc_html__( 'WooCommerce Required', 'admore-widgets-suite' ) . '

' . esc_html__( 'Please install and activate WooCommerce to use this widget.', 'admore-widgets-suite' ) . '

'; } return; } $s = $this->get_settings_for_display(); $product_id = ( 'manual' === $s['product_source'] ) ? absint( $s['product_id'] ) : get_the_ID(); $product = $product_id ? wc_get_product( $product_id ) : null; if ( ! $product ) { if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) { echo '

' . esc_html__( 'No product found', 'admore-widgets-suite' ) . '

' . esc_html__( 'Enter a valid Product ID, or use this widget on a product page.', 'admore-widgets-suite' ) . '

'; } return; } $show_qty = 'yes' === $s['show_quantity']; $btn_text = ! empty( $s['button_text'] ) ? esc_html( $s['button_text'] ) : esc_html( $product->single_add_to_cart_text() ); ?>
is_purchasable() && $product->is_in_stock() ) : ?>
apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ), 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ), // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound 'input_value' => 1, ], $product ); ?>
is_in_stock() ) : ?>