Create New Item
×
Item Type
File
Folder
Item Name
×
Search file in folder and subfolders...
File Manager
/
wp-content
/
plugins
/
powerpack-elements
/
modules
/
woocommerce
/
widgets
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace PowerpackElements\Modules\Woocommerce\Widgets; use PowerpackElements\Base\Powerpack_Widget; use Elementor\Controls_Manager; use Elementor\Group_Control_Background; use Elementor\Group_Control_Border; use Elementor\Group_Control_Box_Shadow; use Elementor\Core\Schemes\Typography as Scheme_Typography; use Elementor\Group_Control_Typography; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } class Woo_Add_To_Cart_Notification extends Powerpack_Widget { public function get_categories() { return parent::get_woo_categories(); } /** * Retrieve toggle widget name. * * @access public * * @return string Widget name. */ public function get_name() { return parent::get_widget_name( 'Woo_Add_To_Cart_Notification' ); } /** * Retrieve toggle widget title. * * @access public * * @return string Widget title. */ public function get_title() { return parent::get_widget_title( 'Woo_Add_To_Cart_Notification' ); } /** * Retrieve toggle widget icon. * * @access public * * @return string Widget icon. */ public function get_icon() { return parent::get_widget_icon( 'Woo_Add_To_Cart_Notification' ); } /** * Get widget keywords. * * Retrieve the list of keywords the widget belongs to. * * @since 1.4.13.4 * @access public * * @return array Widget keywords. */ public function get_keywords() { return parent::get_widget_keywords( 'Woo_Add_To_Cart_Notification' ); } /** * Retrieve the list of scripts the toggle widget depended on. * * Used to set scripts dependencies required to run the widget. * * @access public * * @return array Widget scripts dependencies. */ public function get_script_depends() { return array( 'pp-woocommerce', ); } /** * Retrieve the list of styles the Woo - My Account depended on. * * Used to set style dependencies required to run the widget. * * @access public * * @return array Widget scripts dependencies. */ public function get_style_depends() { return array( 'pp-woocommerce', ); } protected function _register_controls() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore $this->start_controls_section( 'section_box_style', [ 'label' => __( 'Box', 'powerpack' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Background::get_type(), array( 'name' => 'box_background', 'types' => array( 'classic', 'gradient' ), 'selector' => '{{WRAPPER}} .pp-add-to-cart-sticky', ) ); $this->add_group_control( Group_Control_Border::get_type(), array( 'name' => 'box_border', 'label' => __( 'Border', 'powerpack' ), 'placeholder' => '1px', 'default' => '1px', 'selector' => '{{WRAPPER}} .pp-add-to-cart-sticky', ) ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), array( 'name' => 'box_shadow', 'separator' => 'before', 'selector' => '{{WRAPPER}} .pp-add-to-cart-sticky', ) ); $this->add_responsive_control( 'box_padding', array( 'label' => __( 'Padding', 'powerpack' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', 'em', '%' ), 'selectors' => array( '{{WRAPPER}} .pp-add-to-cart-sticky' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->end_controls_section(); $this->start_controls_section( 'section_image_style', [ 'label' => __( 'Image', 'powerpack' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'image_width', array( 'label' => __( 'Width', 'powerpack' ), 'type' => Controls_Manager::SLIDER, 'size_units' => array( 'px', '%' ), 'range' => array( 'px' => array( 'min' => 0, 'max' => 500, ), '%' => array( 'min' => 0, 'max' => 100, ), ), 'selectors' => array( '{{WRAPPER}} .pp-add-to-cart-sticky .pp-sticky-thumbnail img' => 'max-width: {{SIZE}}{{UNIT}};', ), ) ); $this->add_responsive_control( 'image_spacing', array( 'label' => __( 'Spacing', 'powerpack' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em' ], 'range' => array( 'px' => array( 'min' => 0, 'max' => 100, ), ), 'selectors' => array( '{{WRAPPER}} .pp-add-to-cart-sticky .pp-sticky-thumbnail' => 'margin-right: {{SIZE}}{{UNIT}};', ), ) ); $this->add_group_control( Group_Control_Border::get_type(), array( 'name' => 'image_border', 'label' => __( 'Border', 'powerpack' ), 'placeholder' => '1px', 'default' => '1px', 'selector' => '{{WRAPPER}} .pp-add-to-cart-sticky .pp-sticky-thumbnail img', ) ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), array( 'name' => 'image_shadow', 'separator' => 'before', 'selector' => '{{WRAPPER}} .pp-add-to-cart-sticky .pp-sticky-thumbnail img', ) ); $this->add_control( 'image_radius', array( 'label' => __( 'Border Radius', 'powerpack' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'selectors' => array( '{{WRAPPER}} .pp-add-to-cart-sticky .pp-sticky-thumbnail img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->end_controls_section(); $this->start_controls_section( 'section_title_style', [ 'label' => __( 'Title', 'powerpack' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'title_color', [ 'label' => __( 'Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .pp-add-to-cart-sticky .add-to-cart-title' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'title_typography', 'scheme' => Scheme_Typography::TYPOGRAPHY_4, 'selector' => '{{WRAPPER}} .pp-add-to-cart-sticky .add-to-cart-title', ] ); $this->add_responsive_control( 'title_spacing', [ 'label' => __( 'Spacing', 'powerpack' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em' ], 'range' => [ 'em' => [ 'min' => 0, 'max' => 5, 'step' => 0.1, ], ], 'selectors' => [ '{{WRAPPER}} .pp-add-to-cart-sticky .add-to-cart-title' => 'margin-bottom: {{SIZE}}{{UNIT}}', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'section_price_style', [ 'label' => __( 'Price', 'powerpack' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'price_color', [ 'label' => __( 'Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '.woocommerce {{WRAPPER}} .add-to-cart-price' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'typography', 'scheme' => Scheme_Typography::TYPOGRAPHY_4, 'selector' => '.woocommerce {{WRAPPER}} .add-to-cart-price', ] ); $this->add_control( 'sale_heading', [ 'label' => __( 'Sale Price', 'powerpack' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_control( 'sale_price_color', [ 'label' => __( 'Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '.woocommerce {{WRAPPER}} .add-to-cart-price ins' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'sale_price_typography', 'scheme' => Scheme_Typography::TYPOGRAPHY_4, 'selector' => '.woocommerce {{WRAPPER}} .add-to-cart-price ins', ] ); $this->end_controls_section(); $this->start_controls_section( 'section_button_style', [ 'label' => __( 'Button', 'powerpack' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'button_typography', 'selector' => '{{WRAPPER}} .cart button', ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'button_border', 'selector' => '{{WRAPPER}} .cart button', 'exclude' => [ 'color' ], ] ); $this->add_control( 'button_border_radius', [ 'label' => __( 'Border Radius', 'powerpack' ), 'type' => Controls_Manager::DIMENSIONS, 'selectors' => [ '{{WRAPPER}} .cart button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'button_padding', [ 'label' => __( 'Padding', 'powerpack' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em' ], 'selectors' => [ '{{WRAPPER}} .cart button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->start_controls_tabs( 'button_style_tabs' ); $this->start_controls_tab( 'button_style_normal', [ 'label' => __( 'Normal', 'powerpack' ), ] ); $this->add_control( 'button_text_color', [ 'label' => __( 'Text Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .cart button' => 'color: {{VALUE}}', ], ] ); $this->add_control( 'button_bg_color', [ 'label' => __( 'Background Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .cart button' => 'background-color: {{VALUE}}', ], ] ); $this->add_control( 'button_border_color', [ 'label' => __( 'Border Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .cart button' => 'border-color: {{VALUE}}', ], ] ); $this->end_controls_tab(); $this->start_controls_tab( 'button_style_hover', [ 'label' => __( 'Hover', 'powerpack' ), ] ); $this->add_control( 'button_text_color_hover', [ 'label' => __( 'Text Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .cart button:hover' => 'color: {{VALUE}}', ], ] ); $this->add_control( 'button_bg_color_hover', [ 'label' => __( 'Background Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .cart button:hover' => 'background-color: {{VALUE}}', ], ] ); $this->add_control( 'button_border_color_hover', [ 'label' => __( 'Border Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .cart button:hover' => 'border-color: {{VALUE}}', ], ] ); $this->add_control( 'button_transition', [ 'label' => __( 'Transition Duration', 'powerpack' ), 'type' => Controls_Manager::SLIDER, 'default' => [ 'size' => 0.2, ], 'range' => [ 'px' => [ 'max' => 2, 'step' => 0.1, ], ], 'selectors' => [ '{{WRAPPER}} .cart button' => 'transition: all {{SIZE}}s', ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->add_control( 'quantity_heading', [ 'label' => __( 'Quantity', 'powerpack' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_control( 'spacing', [ 'label' => __( 'Spacing', 'powerpack' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em' ], 'selectors' => [ 'body:not(.rtl) {{WRAPPER}} .quantity + .button' => 'margin-left: {{SIZE}}{{UNIT}}', 'body.rtl {{WRAPPER}} .quantity + .button' => 'margin-right: {{SIZE}}{{UNIT}}', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'quantity_typography', 'selector' => '{{WRAPPER}} .quantity .qty', ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'quantity_border', 'selector' => '{{WRAPPER}} .quantity .qty', 'exclude' => [ 'color' ], ] ); $this->add_control( 'quantity_border_radius', [ 'label' => __( 'Border Radius', 'powerpack' ), 'type' => Controls_Manager::DIMENSIONS, 'selectors' => [ '{{WRAPPER}} .quantity .qty' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'quantity_padding', [ 'label' => __( 'Padding', 'powerpack' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em' ], 'selectors' => [ '{{WRAPPER}} .quantity .qty' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->start_controls_tabs( 'quantity_style_tabs' ); $this->start_controls_tab( 'quantity_style_normal', [ 'label' => __( 'Normal', 'powerpack' ), ] ); $this->add_control( 'quantity_text_color', [ 'label' => __( 'Text Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .quantity .qty' => 'color: {{VALUE}}', ], ] ); $this->add_control( 'quantity_bg_color', [ 'label' => __( 'Background Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .quantity .qty' => 'background-color: {{VALUE}}', ], ] ); $this->add_control( 'quantity_border_color', [ 'label' => __( 'Border Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .quantity .qty' => 'border-color: {{VALUE}}', ], ] ); $this->end_controls_tab(); $this->start_controls_tab( 'quantity_style_focus', [ 'label' => __( 'Focus', 'powerpack' ), ] ); $this->add_control( 'quantity_text_color_focus', [ 'label' => __( 'Text Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .quantity .qty:focus' => 'color: {{VALUE}}', ], ] ); $this->add_control( 'quantity_bg_color_focus', [ 'label' => __( 'Background Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .quantity .qty:focus' => 'background-color: {{VALUE}}', ], ] ); $this->add_control( 'quantity_border_color_focus', [ 'label' => __( 'Border Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .quantity .qty:focus' => 'border-color: {{VALUE}}', ], ] ); $this->add_control( 'quantity_transition', [ 'label' => __( 'Transition Duration', 'powerpack' ), 'type' => Controls_Manager::SLIDER, 'default' => [ 'size' => 0.2, ], 'range' => [ 'px' => [ 'max' => 2, 'step' => 0.1, ], ], 'selectors' => [ '{{WRAPPER}} .quantity .qty' => 'transition: all {{SIZE}}s', ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->add_control( 'variations_heading', [ 'label' => __( 'Variations', 'powerpack' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_control( 'variations_width', [ 'label' => __( 'Width', 'powerpack' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ '%' ], 'default' => [ 'unit' => '%', ], 'selectors' => [ '.woocommerce {{WRAPPER}} form.cart .variations' => 'width: {{SIZE}}{{UNIT}}', ], ] ); $this->add_control( 'variations_spacing', [ 'label' => __( 'Spacing', 'powerpack' ), 'type' => Controls_Manager::SLIDER, 'selectors' => [ '.woocommerce {{WRAPPER}} form.cart .variations' => 'margin-bottom: {{SIZE}}{{UNIT}}', ], ] ); $this->add_control( 'variations_space_between', [ 'label' => __( 'Space Between', 'powerpack' ), 'type' => Controls_Manager::SLIDER, 'selectors' => [ '.woocommerce {{WRAPPER}} form.cart table.variations tr:not(:last-child)' => 'margin-bottom: {{SIZE}}{{UNIT}}', ], ] ); $this->add_control( 'heading_variations_label_style', [ 'label' => __( 'Label', 'powerpack' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_control( 'variations_label_color_focus', [ 'label' => __( 'Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '.woocommerce {{WRAPPER}} form.cart table.variations label' => 'color: {{VALUE}}', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'variations_label_typography', 'selector' => '.woocommerce {{WRAPPER}} form.cart table.variations label', ] ); $this->add_control( 'heading_variations_select_style', [ 'label' => __( 'Select field', 'powerpack' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_control( 'variations_select_color', [ 'label' => __( 'Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '.woocommerce {{WRAPPER}} form.cart table.variations td.value select' => 'color: {{VALUE}}', ], ] ); $this->add_control( 'variations_select_bg_color', [ 'label' => __( 'Background Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '.woocommerce {{WRAPPER}} form.cart table.variations td.value:before' => 'background-color: {{VALUE}}', ], ] ); $this->add_control( 'variations_select_border_color', [ 'label' => __( 'Border Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '.woocommerce {{WRAPPER}} form.cart table.variations td.value:before' => 'border: 1px solid {{VALUE}}', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'variations_select_typography', 'selector' => '.woocommerce {{WRAPPER}} form.cart table.variations td.value select, .woocommerce div.product.elementor{{WRAPPER}} form.cart table.variations td.value:before', ] ); $this->add_control( 'variations_select_border_radius', [ 'label' => __( 'Border Radius', 'powerpack' ), 'type' => Controls_Manager::SLIDER, 'selectors' => [ '.woocommerce {{WRAPPER}} form.cart table.variations td.value:before' => 'border-radius: {{SIZE}}{{UNIT}}', ], ] ); $this->add_control( 'stock_heading', [ 'label' => __( 'Stock', 'powerpack' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_control( 'stock_color', [ 'label' => __( 'Text Color', 'powerpack' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '.woocommerce {{WRAPPER}} .stock' => 'color: {{VALUE}}', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'stock_typography', 'label' => __( 'Typography', 'powerpack' ), 'selector' => '.woocommerce {{WRAPPER}} .stock', ] ); $this->add_responsive_control( 'stock_spacing', array( 'label' => __( 'Spacing', 'powerpack' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em' ], 'range' => array( 'px' => array( 'min' => 0, 'max' => 100, ), ), 'selectors' => array( '.woocommerce {{WRAPPER}} .stock' => 'margin-bottom: {{SIZE}}{{UNIT}};', ), ) ); $this->end_controls_section(); } protected function render() { do_action( 'pp_woo_builder_widget_before_render', $this ); global $product; if ( ! is_product() ) { return; } ?> <div class="pp-add-to-cart-notification pp-add-to-cart-sticky"> <div class="pp-add-to-cart-notification-container"> <div class="pp-add-to-cart-content-row clearfix"> <div class="pp-add-to-cart-content-left"> <div class="pp-add-to-cart-content"> <div class="pp-sticky-thumbnail"> <?php echo wp_kses_post( woocommerce_get_product_thumbnail() ); ?> </div> <div class="pp-sticky-product-info"> <h4 class="add-to-cart-title"><?php the_title(); ?></h4> <span class="add-to-cart-price"><?php echo wp_kses_post( $product->get_price_html() ); ?></span> </div> </div> </div> <div class="pp-add-to-cart-content-right"> <div class="pp-sticky-button-area"> <?php if ( $product->is_type( 'simple' ) ) { woocommerce_simple_add_to_cart(); } else { echo '<a href="' . esc_url( $product->add_to_cart_url() ) . '" class="pp-sticky-add-to-cart button alt">' . ( true === $product->is_type( 'variable' ) ? esc_html__( 'Select Options', 'powerpack' ) : wp_kses_post( $product->single_add_to_cart_text() ) ) . '</a>'; } ?> </div> </div> </div> </div> </div> <?php do_action( 'pp_woo_builder_widget_after_render', $this ); } public function render_plain_content() {} }