File: /home/atiscoir/public_html/wp-content/themes/servin/inc/elements/shop/product.php
<?php
namespace Elementor;
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
class TMT_Archive_Product extends Widget_Base{
public function get_name(){
return 'tmt-product';
}
public function get_title(){
return __('Archive Product', text_domain);
}
public function get_icon(){
return 'eicon-products';
}
public function get_style_depends() {
return [ 'swiper' ];
}
public function get_script_depends() {
return [ 'swiper' ];
}
public function get_categories(){
return ['shop_servin'];
}
protected function register_controls(){
$this->register_general_product_grid_controls();
$this->register_general_slider_controls();
$this->register_general_style_product_grid_controls();
$this->register_sort_by_style_product_grid_controls();
$this->register_image_style_product_grid_controls();
$this->register_title_style_product_grid_controls();
$this->register_price_style_product_grid_controls();
$this->register_badge_style_product_grid_controls();
$this->register_pagination_product_grid_controls();
$this->register_text_add_to_cart_product_grid_controls();
$this->register_style_slider_controls();
}
protected function register_general_product_grid_controls(){
$this->start_controls_section(
'section_product_grid',
[
'label' => __('product Settings', text_domain)
]
);
$this->add_control(
'product_type',
[
'label' => __('Post Type', text_domain),
'type' => Controls_Manager::SELECT,
'default' => 'product',
'options' => [
'product' => __('Product', text_domain),
'loop' => __('Loop', text_domain),
'related' => __( 'Related', text_domain ),
'upsell' => __( 'Upsell', text_domain ),
'cross_sells' => __( 'Cross Sells', text_domain ),
],
]
);
$this->add_control(
'show_product_type',
[
'label' => esc_html__('Show Product', text_domain),
'type' => Controls_Manager::SELECT,
'default' => 'all',
'options' => [
'all' => esc_html__('All Products', text_domain),
'onsale' => esc_html__('On Sale', text_domain),
'featured' => esc_html__('Featured', text_domain),
],
'condition' => [
'product_type' => 'product',
],
]
);
$this->add_responsive_control(
'product_grid_columns',
[
'label' => __('Number of Columns', text_domain),
'type' => Controls_Manager::SELECT,
'options' => [
'100%' => __('1 Columns', text_domain),
'50%' => __('2 Columns', text_domain),
'33.333333%' => __('3 Columns', text_domain),
'25%' => __('4 Columns', text_domain),
'20%' => __('5 Columns', text_domain),
'16.666667%' => __('6 Columns', text_domain),
],
'devices' => ['desktop', 'tablet', 'mobile'],
'desktop_default' => '33.333333%',
'tablet_default' => '50%',
'mobile_default' => '100%',
'selectors' => [
'{{WRAPPER}} .products > *' => '-ms-flex: 0 0 {{VALUE}};flex: 0 0 {{VALUE}};max-width: {{VALUE}};',
],
'condition' => [
'enable_slider!' => 'yes'
],
]
);
$this->add_control(
'products_order',
[
'label' => __('Order', text_domain),
'type' => Controls_Manager::SELECT,
'options' => [
'asc' => __('Ascending', text_domain),
'desc' => __('Descending', text_domain)
],
'condition' => [
'product_type!' => 'loop',
],
'default' => 'desc',
]
);
$this->add_control(
'orderby',
[
'label' => esc_html__('Order by', text_domain),
'type' => Controls_Manager::SELECT,
'default' => 'date',
'options' => [
'date' => esc_html__('Date', text_domain),
'price' => esc_html__('Price', text_domain),
'sales' => esc_html__('Sales', text_domain),
'rand' => esc_html__('Random', text_domain),
],
'condition' => [
'product_type' => 'product',
],
]
);
$product_categories = get_terms('product_cat');
$options = [];
foreach ($product_categories as $category) {
$options[$category->slug] = $category->name;
}
$this->add_control(
'product_categories',
[
'label' => esc_html__('Categories', text_domain),
'type' => Controls_Manager::SELECT2,
'options' => $options,
'default' => [],
'label_block' => true,
'multiple' => true,
'condition' => [
'product_type' => 'product',
],
]
);
$this->add_control(
'exclude_products',
[
'label' => esc_html__('Exclude Product(s)', text_domain),
'type' => Controls_Manager::TEXT,
'placeholder' => 'product_id',
'label_block' => true,
'description' => __('Write product id here, if you want to exclude multiple products so use comma as separator. Such as 1 , 2', text_domain),
'condition' => [
'product_type' => 'product',
],
]
);
$this->add_control(
'products_count',
[
'label' => __('Number of Posts', text_domain),
'type' => Controls_Manager::NUMBER,
'default' => '4',
'condition' => [
'product_type!' => 'loop',
],
]
);
$this->add_control(
'title_tag',
[
'label' => __('Title Tag', text_domain),
'type' => Controls_Manager::SELECT,
'label_block' => true,
'multiple' => true,
'options' => TMT_Title_Tags(),
'default' => 'h3',
]
);
$this->add_control(
'text',
[
'label' => __( 'Text Add To Cart', text_domain ),
'type' => Controls_Manager::TEXT,
'default' => __( 'Add To Card', text_domain ),
]
);
$this->add_control(
'enable_slider',
[
'label' => __( 'Enable Slider', text_domain ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', text_domain ),
'label_off' => __( 'Hide', text_domain ),
]
);
$this->add_control(
'show_sale',
[
'label' => __( 'Show Sale', text_domain),
'type' =>Controls_Manager::SWITCHER,
'label_on' => __( 'Show', text_domain ),
'label_off' => __( 'Hide', text_domain ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$this->add_control(
'hide_free',
[
'label' => esc_html__('Hide Free', text_domain),
'type' => Controls_Manager::SWITCHER,
'condition' => [
'product_type' => 'product',
],
]
);
$this->add_control(
'hide_out_stock',
[
'label' => esc_html__('Hide Out of Stock', text_domain),
'type' => Controls_Manager::SWITCHER,
'condition' => [
'product_type' => 'product',
],
]
);
$this->add_control(
'show_pagination',
[
'label' => __('Show Pagination', text_domain),
'type' => Controls_Manager::SWITCHER,
'default' => 'no',
]
);
$this->add_control(
'switch_image',
[
'label' => esc_html__( 'Hover Switch Image', text_domain ),
'type' => Controls_Manager::SWITCHER,
'prefix_class' => 'img-switch-',
]
);
$this->add_responsive_control(
'switch_image_ani',
[
'label' => __( 'Switch Image Animation', text_domain ),
'type' => Controls_Manager::SELECT,
'options' => [
'tada' => 'tada',
'bounce' => 'bounce',
'bounceIn' => 'bounceIn',
'fadeIn' => 'fadeIn',
'zoomIn' => 'zoomIn',
],
'default' => 'tada',
'selectors' => [
'{{WRAPPER}}.img-switch-yes .product:hover .item img' => '-webkit-animation-name: {{VALUE}};animation-name: {{VALUE}};',
],
'condition' => [
'switch_image' => 'yes',
],
]
);
$this->add_control(
'remove_sort_by',
[
'label' => esc_html__( 'Remove Sort By', text_domain ),
'type' => Controls_Manager::SWITCHER,
'prefix_class' => 'remove-sort-by-',
'condition' => [
'product_type' => 'loop',
],
]
);
$this->add_control(
'remove_result_count',
[
'label' => esc_html__( 'Remove Result Count', text_domain ),
'type' => Controls_Manager::SWITCHER,
'prefix_class' => 'remove-result-count-',
'condition' => [
'product_type' => 'loop',
],
]
);
$this->end_controls_section();
}
protected function register_general_slider_controls(){
$this->start_controls_section(
'section_slider',
[
'label' => __( 'Slider Settings', text_domain ),
'condition' => [
'enable_slider' => 'yes',
]
]
);
$this->add_control(
'slider_columns',
[
'label' => __( 'Columns', text_domain ),
'type' => Controls_Manager::SELECT,
'options' => [
'1' => __( '1 Columns', text_domain ),
'2' => __( '2 Columns', text_domain ),
'3' => __( '3 Columns', text_domain ),
'4' => __( '4 Columns', text_domain ),
'5' => __( '5 Columns', text_domain ),
'6' => __( '6 Columns', text_domain ),
],
'default' => '4',
'frontend_available' => true,
'condition' => [
'enable_slider' => 'yes',
],
]
);
$this->add_control(
'column_tablet',
[
'label' => __( 'Columns Tablet', text_domain ),
'type' => Controls_Manager::SELECT,
'options' => [
'1' => __( '1 Columns', text_domain ),
'2' => __( '2 Columns', text_domain ),
'3' => __( '3 Columns', text_domain ),
'4' => __( '4 Columns', text_domain ),
'5' => __( '5 Columns', text_domain ),
'6' => __( '6 Columns', text_domain ),
],
'default' => '2',
'frontend_available' => true,
'condition' => [
'enable_slider' => 'yes',
],
]
);
$this->add_control(
'column_mobile',
[
'label' => __( 'Columns Mobile', text_domain ),
'type' => Controls_Manager::SELECT,
'options' => [
'1' => __( '1 Columns', text_domain ),
'2' => __( '2 Columns', text_domain ),
'3' => __( '3 Columns', text_domain ),
'4' => __( '4 Columns', text_domain ),
'5' => __( '5 Columns', text_domain ),
'6' => __( '6 Columns', text_domain ),
],
'default' => '1',
'frontend_available' => true,
'condition' => [
'enable_slider' => 'yes',
],
]
);
$this->add_control(
'navigation',
[
'label' => __( 'Navigation', text_domain ),
'type' => Controls_Manager::SELECT,
'default' => 'both',
'options' => [
'both' => __( 'Arrows and Dots', text_domain ),
'arrows' => __( 'Arrows', text_domain ),
'dots' => __( 'Dots', text_domain ),
'none' => __( 'None', text_domain ),
],
]
);
$this->add_control(
'pause_on_hover',
[
'label' => __( 'Pause on Hover', text_domain ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
]
);
$this->add_control(
'autoplay',
[
'label' => __( 'Autoplay', text_domain ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
]
);
$this->add_control(
'autoplay_speed',
[
'label' => __( 'Autoplay Speed', text_domain ),
'type' => Controls_Manager::NUMBER,
'default' => 2000,
'condition' => [
'autoplay' => 'yes',
],
]
);
$this->add_control(
'infinite',
[
'label' => __( 'Infinite Loop', text_domain ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
]
);
$this->add_control(
'centerMode',
[
'label' => __( 'Center Mode', text_domain ),
'type' => Controls_Manager::SWITCHER,
]
);
$this->add_control(
'effect',
[
'label' => __( 'Effect', text_domain ),
'type' => Controls_Manager::SELECT,
'default' => 'none',
'options' => [
'none' => __( 'None', text_domain ),
'fade' => __( 'Fade', text_domain ),
'cube' => __( 'Cube', text_domain ),
'coverflow' => __( 'Coverflow', text_domain ),
'flip' => __( 'Flip', text_domain ),
'cards' => __( 'Cards', text_domain ),
'creative' => __( 'Creative', text_domain ),
],
]
);
$this->add_control(
'creative_type',
[
'label' => __( 'Creative Type', text_domain ),
'type' => Controls_Manager::SELECT,
'default' => '1',
'options' => [
'1' => __( 'Type', text_domain ) . ' 1',
'2' => __( 'Type', text_domain ) . ' 2',
'3' => __( 'Type', text_domain ) . ' 3',
'4' => __( 'Type', text_domain ) . ' 4',
'5' => __( 'Type', text_domain ) . ' 5',
'6' => __( 'Type', text_domain ) . ' 6',
],
'condition' => [
'effect' => 'creative'
],
]
);
$this->end_controls_section();
}
protected function register_general_style_product_grid_controls(){
$this->start_controls_section(
'general_style',
[
'label' => esc_html__('General', text_domain),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'item_gap',
[
'label' => esc_html__('Column Gap', text_domain),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'size' => 10,
],
'selectors' => [
'{{WRAPPER}} .content-shopping' => 'padding-right: {{SIZE}}px;padding-left: {{SIZE}}px',
],
]
);
$this->add_responsive_control(
'row_gap',
[
'label' => esc_html__('Row Gap', text_domain),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'size' => 10,
],
'selectors' => [
'{{WRAPPER}} .content-shopping' => 'padding-top: {{SIZE}}px;padding-bottom: {{SIZE}}px',
],
]
);
$this->start_controls_tabs('tabs_item_style');
$this->start_controls_tab('tab_item_normal',['label' => esc_html__('Normal', text_domain),]);
$this->add_control(
'item_background',
[
'label' => esc_html__('Background', text_domain),
'type' => Controls_Manager::COLOR,
'default' => '#F2F2F2',
'selectors' => [
'{{WRAPPER}} .item' => 'background-color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'item_padding',
[
'label' => esc_html__('Item Padding', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .content-shopping .item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'item_margin',
[
'label' => esc_html__('Item margin', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .content-shopping .item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'item_radius',
[
'label' => esc_html__('Border Radius', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'default' => [
'top' => '5',
'right' => '5',
'bottom' => '5',
'left' => '5',
'unit' => 'px',
'isLinked' => false,
],
'selectors' => [
'{{WRAPPER}} .content-shopping .item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};overflow: hidden;',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'item_border',
'label' => esc_html__('Border Color', text_domain),
'selector' => '{{WRAPPER}} .item',
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'item_shadow',
'selector' => '{{WRAPPER}} .content-shopping .item',
]
);
$this->end_controls_tab();
$this->start_controls_tab('tab_item_hover',['label' => esc_html__('Hover', text_domain),]);
$this->add_control(
'item_hover_background',
[
'label' => esc_html__('Background', text_domain),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .content-shopping .item:hover' => 'background-color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'item_hover_adius',
[
'label' => esc_html__('Border Radius', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'default' => [
'top' => '5',
'right' => '5',
'bottom' => '5',
'left' => '5',
'unit' => 'px',
'isLinked' => false,
],
'selectors' => [
'{{WRAPPER}} .content-shopping .item:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};overflow: hidden;',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'item_border_hover',
'label' => esc_html__('Border Color', text_domain),
'selector' => '{{WRAPPER}} .item:hover',
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'item_hover_shadow',
'selector' => '{{WRAPPER}} .content-shopping .item:hover',
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
}
protected function register_sort_by_style_product_grid_controls(){
$this->start_controls_section(
'sort_by_style',
[
'label' => esc_html__('Sort By', text_domain),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'product_type' => 'loop',
],
]
);
$this->start_controls_tabs('sort_by_style_tabs');
$this->start_controls_tab('sort_by_style_normal_tab', ['label' => __('Normal', text_domain),]);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'sort_by_typography',
'label' => esc_html__('Typography', text_domain),
'selector' => '{{WRAPPER}} .sort-by',
]
);
$this->add_control(
'sort_by_color',
[
'label' => esc_html__('Color', text_domain),
'type' => Controls_Manager::COLOR,
'default' => '#20262A',
'selectors' => [
'{{WRAPPER}} .sort-by,{{WRAPPER}} .sort-by a' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'sort_by_bg_color',
[
'label' => esc_html__('Bachground Color', text_domain),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .sort-by a' => 'background-color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'sort_by_margin',
[
'label' => esc_html__('Margin', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .sort-by a' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'sort_by_shadow',
'selector' => '{{WRAPPER}} .sort-by a',
]
);
$this->add_responsive_control(
'sort_by_padding',
[
'label' => esc_html__('Padding', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'default' => [
'top' => '5',
'right' => '10',
'bottom' => '5',
'left' => '10',
'unit' => 'px',
'isLinked' => false,
],
'selectors' => [
'{{WRAPPER}} .sort-by a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'sort_by_border_radius',
[
'label' => esc_html__('Border Radius', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'default' => [
'top' => '5',
'right' => '5',
'bottom' => '5',
'left' => '5',
'unit' => 'px',
'isLinked' => false,
],
'selectors' => [
'{{WRAPPER}} .sort-by a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'sort_by_color_icon',
[
'label' => esc_html__('Color Icon', text_domain),
'type' => Controls_Manager::COLOR,
'default' => '#eead16',
'selectors' => [
'{{WRAPPER}} .sort-by i' => 'color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab('sort_by_style_active_tab', ['label' => __('Active', text_domain),]);
$this->add_control(
'active_by_bg_color',
[
'label' => esc_html__('Hover Color', text_domain),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
'{{WRAPPER}} .sort-by a:hover,{{WRAPPER}} .sort-by a.active' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'active_sort_by_bg_color',
[
'label' => esc_html__('Bachground Color', text_domain),
'type' => Controls_Manager::COLOR,
'default' => '#eead16',
'selectors' => [
'{{WRAPPER}} .sort-by a:hover,{{WRAPPER}} .sort-by a.active' => 'background-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
}
protected function register_image_style_product_grid_controls(){
$this->start_controls_section(
'image_style',
[
'label' => esc_html__('Image', text_domain),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'object_fit',
[
'label' => __('Image Fit', text_domain),
'type' => Controls_Manager::SELECT,
'options' => [
'inherit' => __('None', text_domain),
'cover' => __('Cover', text_domain),
'contain' => __('Contain', text_domain),
'fill' => __('Fill', text_domain),
'scale-down' => __('Scale Down', text_domain),
],
'default' => 'inherit',
'selectors' => [
'{{WRAPPER}} img' => 'object-fit: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'height_img',
[
'label' => esc_html__('Height', text_domain),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
],
],
'selectors' => [
'{{WRAPPER}} .product img' => 'height:{{SIZE}}px',
],
]
);
$this->add_control(
'bg_hover_color',
[
'label' => __('Hover Post Background Color', text_domain),
'type' => Controls_Manager::COLOR,
'default' => '#FFBC00AB',
'selectors' => [
'{{WRAPPER}} .hover-shope:after' => 'background-color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'width_ani_img',
[
'label' => esc_html__('Width', text_domain),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'size' => 50,
],
'selectors' => [
'{{WRAPPER}} .hover-shope::after' => 'width: {{SIZE}}%;height:{{SIZE}}%',
],
]
);
$this->add_responsive_control(
'height_ani_img',
[
'label' => esc_html__('Height', text_domain),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'size' => 40,
],
'selectors' => [
'{{WRAPPER}} .hover-shope::after' => 'height:{{SIZE}}%',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'image_border',
'label' => esc_html__('Image Border', text_domain),
'selector' => '{{WRAPPER}} img',
]
);
$this->add_responsive_control(
'image_border_radius',
[
'label' => esc_html__('Border Radius', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'image_shadow',
'exclude' => [
'shadow_position',
],
'selector' => '{{WRAPPER}} img',
]
);
$this->end_controls_section();
}
protected function register_title_style_product_grid_controls(){
$this->start_controls_section(
'title_style',
[
'label' => esc_html__('Title', text_domain),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__('Color', text_domain),
'type' => Controls_Manager::COLOR,
'default' => '#2B2B2B',
'selectors' => [
'{{WRAPPER}} .hover-shope .title ' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'hover_title_color',
[
'label' => esc_html__('Hover Color', text_domain),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .hover-shope .title:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'title_padding',
[
'label' => esc_html__(' Padding', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .hover-shope .title ' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'title_margin',
[
'label' => esc_html__('Margin', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .hover-shope .title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'title_border',
'selector' => '{{WRAPPER}} .title',
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => __( 'Typography', text_domain ),
'selector' => '{{WRAPPER}} .title',
]
);
$this->end_controls_section();
}
protected function register_text_add_to_cart_product_grid_controls(){
$this->start_controls_section(
'text_add_to_cart_style',
[
'label' => esc_html__('Text Add To Cart', text_domain),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'align_add_to_cart',
[
'label' => __('Alignment', text_domain),
'type' => Controls_Manager::CHOOSE,
'default' => 'center',
'options' => [
'left' => [
'title' => __('Left', text_domain),
'icon' => 'eicon-h-align-left',
],
'center' => [
'title' => __('Center', text_domain),
'icon' => 'eicon-h-align-center',
],
'right' => [
'title' => __('Right', text_domain),
'icon' => 'eicon-h-align-right',
],
],
]
);
$this->add_control(
'text_add_to_cart_color',
[
'label' => esc_html__('Color', text_domain),
'type' => Controls_Manager::COLOR,
'default' => '#2B2B2B',
'selectors' => [
'{{WRAPPER}} .item .basket-shop' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'hover_text_add_to_cart_color',
[
'label' => esc_html__('Hover Color', text_domain),
'type' => Controls_Manager::COLOR,
'default' => ' #FFBC00',
'selectors' => [
'{{WRAPPER}} .item .basket-shop:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'bg_text_add_to_cart_color',
[
'label' => esc_html__('Background Color', text_domain),
'type' => Controls_Manager::COLOR,
'default' => '#FFBC00',
'selectors' => [
'{{WRAPPER}} .item .basket-shop' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'hover_bg_text_add_to_cart_color',
[
'label' => esc_html__('Hover Background Color', text_domain),
'type' => Controls_Manager::COLOR,
'default' => '#2B2B2B',
'selectors' => [
'{{WRAPPER}} .item .basket-shop:hover' => 'background-color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'bg_text_add_to_cart_height',
[
'label' => __( 'Height', text_domain ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 50,
'max' => 150,
],
'%' => [
'min' => 10,
'max' => 30,
],
],
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .item .basket-shop' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'bg_text_add_to_cart_width',
[
'label' => __( ' Width', text_domain ),
'type' => Controls_Manager::SLIDER,
'range' => [
'%' => [
'min' => 10,
'max' => 100,
],
'px' => [
'min' => 50,
'max' => 500,
],
],
'size_units' => [ '%', 'px' ],
'selectors' => [
'{{WRAPPER}} .item .basket-shop' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'bg_text_add_to_cart_padding',
[
'label' => esc_html__('padding', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'default' => [
'top' => '5',
'right' => '5',
'bottom' => '5',
'left' => '5',
'unit' => 'px',
],
'selectors' => [
'{{WRAPPER}} .item .basket-shop' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'basket-shop_typography',
'label' => esc_html__('Typography', text_domain),
'selector' => '{{WRAPPER}} .item .basket-shop',
]
);
$this->end_controls_section();
}
protected function register_price_style_product_grid_controls(){
$this->start_controls_section(
'style_price',
[
'label' => esc_html__('Price', text_domain),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'align_price',
[
'label' => __('Alignment', text_domain),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __('Left', text_domain),
'icon' => 'eicon-h-align-left',
],
'center' => [
'title' => __('Center', text_domain),
'icon' => 'eicon-h-align-center',
],
'right' => [
'title' => __('Right', text_domain),
'icon' => 'eicon-h-align-right',
],
],
'default' => 'center',
'selectors' => [
'{{WRAPPER}} .price ,{{WRAPPER}} .price .woocommerce-Price-amount' => 'text-align: {{VALUE}};',
],
]
);
$this->add_control(
'bg_price_color',
[
'label' => esc_html__('Background Color', text_domain),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .price' => 'background-color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'price_padding',
[
'label' => esc_html__('Padding', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'default' => [
'top' => '10',
'right' => '0',
'bottom' => '5',
'left' => '0',
'unit' => 'px',
'isLinked' => false,
],
'selectors' => [
'{{WRAPPER}} .price' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'price_radius',
[
'label' => esc_html__('Border Radius', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .price' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'sale_price_heading',
[
'label' => esc_html__('Price', text_domain),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'sale_price_color',
[
'label' => esc_html__( 'Color', text_domain ),
'type' => Controls_Manager::COLOR,
'default' => '#2B2B2B',
'selectors' => [
'{{WRAPPER}} .price ins,{{WRAPPER}} .price .woocommerce-Price-amount' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'sale_price_typography',
'label' => esc_html__('Typography', text_domain),
'selector' => '{{WRAPPER}} .price ins,{{WRAPPER}} .price .woocommerce-Price-amount',
]
);
$this->add_control(
'old_price_heading',
[
'label' => esc_html__('Price Del', text_domain),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'old_price_color',
[
'label' => esc_html__( 'Color', text_domain ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .price del,{{WRAPPER}} .price del .woocommerce-Price-amount' => 'color: {{VALUE}} !important;',
],
]
);
$this->add_responsive_control(
'price_width',
[
'label' => __('Width', text_domain),
'type' => Controls_Manager::SLIDER,
'range' => [
'%' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'size' => 30,
],
'size_units' => ['%'],
'selectors' => [
'{{WRAPPER}} .price ins,{{WRAPPER}} .price .woocommerce-Price-amount' => 'min-width: {{SIZE}}%;',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'old_price_typography',
'label' => esc_html__('Typography', text_domain),
'selector' => '{{WRAPPER}} .price del .woocommerce-Price-amount',
]
);
$this->end_controls_section();
}
protected function register_badge_style_product_grid_controls(){
$this->start_controls_section(
'section_style_badge',
[
'label' => esc_html__('Badge', text_domain),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'badge_text_color',
[
'label' => esc_html__('Text Color', text_domain),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
'{{WRAPPER}} .woocommerce .products li.product .onsale ' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'badge_bg_color',
[
'label' => esc_html__('Background Color', text_domain),
'type' => Controls_Manager::COLOR,
'default' => '#FFBC00',
'selectors' => [
'{{WRAPPER}} .woocommerce .products li.product .onsale' => 'background-color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'clip_path_img',
[
'label' => __( 'Broken', text_domain ),
'description' => sprintf(__('For example: <b>%1s</b> or Go <a href="%2s" target="_blank">this link</a> and copy and paste the radius value.', text_domain), '91% 0%, 0% 0%, 0% 100%, 140% 100%', 'https://bennettfeely.com/clippy'),
'type' => Controls_Manager::TEXTAREA,
'default' => '1% 0, 0% 100%, 100% 0',
'rows' => 1,
'selectors' => [
'{{WRAPPER}} .woocommerce .products li.product .onsale' => 'clip-path: polygon({{VALUE}});',
],
]
);
$this->add_responsive_control(
'width_badge',
[
'label' => esc_html__('Width', text_domain),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'size' => 31,
],
'selectors' => [
'{{WRAPPER}} .woocommerce .products li.product .onsale' => 'width:{{SIZE}}%',
],
]
);
$this->add_responsive_control(
'height_badge',
[
'label' => esc_html__('Height', text_domain),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'size' => 28,
],
'selectors' => [
'{{WRAPPER}} .woocommerce .products li.product .onsale' => 'height:{{SIZE}}%',
],
]
);
$this->add_responsive_control(
'po_badge_top',
[
'label' => esc_html__('Position Vertical', text_domain),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .woocommerce .products li.product .onsale' => 'top: {{SIZE}}%;height:{{SIZE}}%',
],
]
);
$this->add_responsive_control(
'po_badge_left',
[
'label' => esc_html__('Position Horizon', text_domain),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .woocommerce .products li.product .onsale' => 'left: {{SIZE}}%;height:{{SIZE}}%',
],
]
);
$this->add_responsive_control(
'badge_padding',
[
'label' => esc_html__('Padding', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'default' => [
'top' => '0',
'right' => '17',
'bottom' => '11',
'left' => '0',
'unit' => '%',
'isLinked' => false,
],
'selectors' => [
'{{WRAPPER}} .woocommerce .products li.product .onsale' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'badge_margin',
[
'label' => esc_html__('Margin', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .woocommerce .products li.product .onsale' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'badge_border_radius',
[
'label' => esc_html__('Border Radius', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'default' => [
'top' => '0',
'right' => '0',
'bottom' => '0',
'left' => '0',
'unit' => 'px',
],
'selectors' => [
'{{WRAPPER}} .woocommerce .products li.product .onsale' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'badge_border',
'label' => esc_html__('Border', text_domain),
'selector' => '{{WRAPPER}} .woocommerce .products li.product .onsale',
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'badge_typography',
'label' => esc_html__('Typography', text_domain),
'selector' => '{{WRAPPER}} .woocommerce .products li.product .onsale ',
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'badge_shadow',
'selector' => '{{WRAPPER}} .woocommerce .products li.product .onsale',
'separator' => 'before',
]
);
$this->end_controls_section();
}
protected function register_pagination_product_grid_controls(){
$this->start_controls_section(
'section_pagination_post_grid_style',
[
'label' => __('Pagination', text_domain),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->start_controls_tabs('style_tabs_navigation');
$this->start_controls_tab('style_normal_navigation_tab', ['label' => __( 'Normal', text_domain ),]);
$this->add_control(
'align_navigation',
[
'label' => __( 'Align Navigation', text_domain ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __( 'Left', text_domain ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => __( 'Center', text_domain ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => __( 'Right', text_domain ),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'center',
'toggle' => true,
'selectors' => [
'{{WRAPPER}} .navigation,{{WRAPPER}} .woocommerce-pagination' => 'display: flex ; align-items:center; justify-content:{{VALUE}}',
],
]
);
$this->add_control(
'color_navigation',
[
'label' => __( 'Color Navigation', text_domain ),
'type' => Controls_Manager::COLOR,
'default' => '#0009',
'selectors' => [
'{{WRAPPER}} .nav-links a,{{WRAPPER}} .woocommerce-pagination span,{{WRAPPER}} .woocommerce-pagination a' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'bg_color_navigation',
[
'label' => __( 'Background Color Navigation', text_domain ),
'type' => Controls_Manager::COLOR,
'default' => '#FFBC00',
'selectors' => [
'{{WRAPPER}} .nav-links a,{{WRAPPER}} .woocommerce-pagination span,{{WRAPPER}} .woocommerce-pagination a' => 'Background: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'border_navigation',
'label' => __( 'Border Navigation', text_domain ),
'selector' => '{{WRAPPER}} .nav-links a,{{WRAPPER}} .nav-links span,
{{WRAPPER}} .woocommerce-pagination span,{{WRAPPER}} .woocommerce-pagination a',
]
);
$this->add_responsive_control(
'padding_navigation',
[
'label' => __( 'Padding Navigation', text_domain ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'default' => [
'top' => 7,
'right' => 15,
'bottom' => 4,
'left' => 15,
],
'selectors' => [
'{{WRAPPER}} .nav-links a,{{WRAPPER}} .nav-links span, {{WRAPPER}} .woocommerce-pagination span,{{WRAPPER}} .woocommerce-pagination a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'margin_navigation',
[
'label' => __( 'Margin Navigation', text_domain ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .nav-links a,{{WRAPPER}} .nav-links span , {{WRAPPER}} .nav-links ,{{WRAPPER}} .woocommerce-pagination span,{{WRAPPER}} .woocommerce-pagination a' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'border_radius_navigation',
[
'label' => __( 'Border Radius Navigation', text_domain ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'default' => [
'top' => 50,
'right' => 15,
'bottom' => 50,
'left' => 50,
],
'selectors' => [
'{{WRAPPER}} .nav-links a , {{WRAPPER}} .nav-links span ,{{WRAPPER}} .woocommerce-pagination span,{{WRAPPER}} .woocommerce-pagination a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab('style_hover_navigation_tab', ['label' => __( 'Hover', text_domain ),]);
$this->add_control(
'hover_color_navigation',
[
'label' => __( 'Hover Navigation', text_domain ),
'type' => Controls_Manager::COLOR,
'default' => '#FFBC00',
'selectors' => [
'{{WRAPPER}} .nav-links a:hover, .woocommerce-pagination span.current,{{WRAPPER}} .woocommerce-pagination a:hover' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'hover_bg_color_navigation',
[
'label' => __( 'Background Hover Navigation', text_domain ),
'type' => Controls_Manager::COLOR,
'default' => '#0009',
'selectors' => [
'{{WRAPPER}} .nav-links a:hover,{{WRAPPER}} .woocommerce-pagination span.current,{{WRAPPER}} .woocommerce-pagination a:hover' => 'Background: {{VALUE}}',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab('style_active_tab', ['label' => __( 'Active', text_domain ),]);
$this->add_control(
'active_color_navigation',
[
'label' => __( 'Active Navigation', text_domain ),
'type' => Controls_Manager::COLOR,
'default' => '#FFBC00',
'selectors' => [
'{{WRAPPER}} .nav-links span,{{WRAPPER}} .woocommerce-pagination span' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'active_bg_color_navigation',
[
'label' => __( 'Background Active Navigation', text_domain ),
'type' => Controls_Manager::COLOR,
'default' => '#0009',
'selectors' => [
'{{WRAPPER}} .nav-links span,{{WRAPPER}} .woocommerce-pagination span' => 'Background: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'border_navigation_active',
'label' => __( 'Border Navigation', text_domain ),
'selector' => '{{WRAPPER}} .nav-links span,{{WRAPPER}} .woocommerce-pagination span',
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
}
protected function register_style_slider_controls() {
$this->start_controls_section(
'section_style_navigation',
[
'label' => __( 'Navigation', text_domain ),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'enable_slider' => 'yes',
'navigation!' => 'none',
],
]
);
// arrows //
$this->add_control(
'heading_style_arrows',
[
'label' => __( 'Arrows', text_domain ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'condition' => [
'navigation' => ['both', 'arrows'],
],
]
);
$this->add_responsive_control(
'right_arrow',
[
'label' => __( 'Right Arrow', text_domain ),
'type' => Controls_Manager::DIMENSIONS,
'allowed_dimensions' => [ 'top', 'right' ],
'default' => [
'top' => '-15',
'right' => '3',
'isLinked' => false,
],
'selectors' => [
'{{WRAPPER}} .swiper-button-prev' => 'top: {{TOP}}%;right: {{RIGHT}}%;left: auto;',
],
'condition' => [
'navigation' => ['both', 'arrows'],
],
]
);
$this->add_responsive_control(
'left_arrow',
[
'label' => __( 'Left Arrow', text_domain ),
'type' => Controls_Manager::DIMENSIONS,
'allowed_dimensions' => [ 'top', 'left' ],
'default' => [
'top' => '-15',
'left' => '3',
'isLinked' => false,
],
'selectors' => [
'{{WRAPPER}} .swiper-button-next' => 'top: {{TOP}}%;left: {{LEFT}}%;right: auto;',
],
'condition' => [
'navigation' => ['both', 'arrows'],
],
]
);
$this->add_control(
'arrows_size',
[
'label' => __( 'Arrows Size', text_domain ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 30,
],
'selectors' => [
'{{WRAPPER}} .tmt-sw-button::after' => 'font-size: {{SIZE}}px;',
],
'condition' => [
'navigation' => ['both', 'arrows'],
],
]
);
$this->start_controls_tabs( 'arrows_icon_tabs' );
$this->start_controls_tab( 'arrows_icon_normal', [
'label' => __( 'Normal', text_domain ),
'condition' => [
'navigation' => ['both', 'arrows'],
],
] );
$this->add_control(
'arrows_color',
[
'label' => __( 'Icon Color', text_domain ),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
'{{WRAPPER}} .tmt-sw-button' => 'color: {{VALUE}};',
],
'condition' => [
'navigation' => ['both', 'arrows'],
],
]
);
$this->add_control(
'arrows_background_color',
[
'label' => __( 'Background Color', text_domain ),
'type' => Controls_Manager::COLOR,
'default' => '#FFBC00',
'selectors' => [
'{{WRAPPER}} .tmt-sw-button' => 'background-color: {{VALUE}};',
],
'condition' => [
'navigation' => ['both', 'arrows'],
],
]
);
$this->end_controls_tab();
$this->start_controls_tab( 'arrows_icon_hover', [
'label' => __( 'Hover', text_domain ),
'condition' => [
'navigation' => ['both', 'arrows'],
],
]);
$this->add_control(
'arrows_hover_color',
[
'label' => __( 'Icon Color', text_domain ),
'type' => Controls_Manager::COLOR,
'default' => '#FFBC00',
'selectors' => [
'{{WRAPPER}} .tmt-sw-button:hover:before' => 'color: {{VALUE}};',
],
'condition' => [
'navigation' => ['both', 'arrows'],
],
]
);
$this->add_control(
'arrows_hover_background_color',
[
'label' => __( 'Background Color', text_domain ),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
'{{WRAPPER}} .tmt-sw-button:hover' => 'background-color: {{VALUE}};',
],
'condition' => [
'navigation' => ['both', 'arrows'],
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_responsive_control(
'arrow_radius',
[
'label' => __('Border Radius', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'default' => [
'top' => '50',
'right' => '50',
'bottom' => '50',
'left' => '50',
'unit' => 'px',
],
'selectors' => [
'{{WRAPPER}} .tmt-sw-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'condition' => [
'navigation' => ['both', 'arrows'],
],
]
);
$this->add_responsive_control(
'arrow_padding',
[
'label' => esc_html__('Padding', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'default' => [
'top' => '20',
'right' => '20',
'bottom' => '20',
'left' => '20',
'unit' => 'px',
],
'selectors' => [
'{{WRAPPER}} .tmt-sw-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'condition' => [
'navigation' => ['both', 'arrows'],
],
]
);
// dots //
$this->add_control(
'heading_style_dots',
[
'label' => __( 'Dots', text_domain ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->add_responsive_control(
'dots_position',
[
'label' => __( 'Dots Position', text_domain ),
'type' => Controls_Manager::DIMENSIONS,
'allowed_dimensions' => [ 'bottom', 'right' ],
'default' => [
'bottom' => '-20',
'right' => '0',
'isLinked' => false,
],
'selectors' => [
'{{WRAPPER}} .swiper-pagination' => 'bottom: {{BOTTOM}}%;right: {{RIGHT}}%;left: auto;',
],
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->start_controls_tabs('style_tabs_dots');
$this->start_controls_tab('style_normal_tab_dots', ['label' => __( 'Normal', 'elementor' ),'condition' => [
'navigation' => ['both', 'dots'],
],]);
$this->add_control(
'dots_color',
[
'label' => __( 'Dots Color', text_domain ),
'type' => Controls_Manager::COLOR,
'default' => '#FFBC00',
'selectors' => [
'{{WRAPPER}} .swiper-pagination span' => 'background-color: {{VALUE}};',
],
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->add_responsive_control(
'dots_slider_width',
[
'label' => __( 'Width', text_domain ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 10,
],
'selectors' => [
'{{WRAPPER}} .swiper-pagination span' => 'width: {{SIZE}}px;',
],
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->add_responsive_control(
'dots_slider_height',
[
'label' => __( 'Height', text_domain ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 10,
],
'selectors' => [
'{{WRAPPER}} .swiper-pagination span' => 'height: {{SIZE}}px;',
],
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->add_responsive_control(
'dots_radius',
[
'label' => __('Border Radius', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'default' => [
'top' => '50',
'right' => '50',
'bottom' => '50',
'left' => '50',
'unit' => 'px',
],
'selectors' => [
'{{WRAPPER}} .swiper-pagination span' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; box-sizing:content-box;',
],
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->add_responsive_control(
'dots_margin',
[
'label' => esc_html__('Margin', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'default' => [
'top' => '0',
'right' => '3',
'bottom' => '0',
'left' => '3',
'unit' => 'px',
],
'selectors' => [
'{{WRAPPER}} .swiper-pagination span' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->end_controls_tab();
$this->start_controls_tab('style_active_tab_dots', ['label' => __( 'Active', 'elementor' ),'condition' => [
'navigation' => ['both', 'dots'],
],]);
$this->add_control(
'active_dot_color',
[
'label' => __( 'Active Dot Color', text_domain ),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
'{{WRAPPER}} .swiper-pagination span.swiper-pagination-bullet-active' => 'background-color: {{VALUE}};',
],
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->add_responsive_control(
'active_dots_slider_width',
[
'label' => __( 'Width', text_domain ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 15,
],
'selectors' => [
'{{WRAPPER}} .swiper-pagination span.swiper-pagination-bullet-active' => 'width: {{SIZE}}px;',
],
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->add_responsive_control(
'active_dots_slider_height',
[
'label' => __( 'Height', text_domain ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 15,
],
'selectors' => [
'{{WRAPPER}} .swiper-pagination span.swiper-pagination-bullet-active' => 'height: {{SIZE}}px;',
],
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->add_responsive_control(
'dots_radius_active',
[
'label' => __('Border Radius', text_domain),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'default' => [
'top' => '50',
'right' => '50',
'bottom' => '50',
'left' => '50',
'unit' => 'px',
],
'selectors' => [
'{{WRAPPER}} .swiper-pagination span.swiper-pagination-bullet-active' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; box-sizing:content-box;',
],
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_control(
'border_dots',
[
'label' => __( 'Border Dots', text_domain ),
'type' => Controls_Manager::HEADING,
'separator' =>'before',
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->start_controls_tabs('style_tabs_outline_dots');
$this->start_controls_tab('style_normal_tab_outline_dots', ['label' => __( 'Normal', 'elementor' ),'condition' => [
'navigation' => ['both', 'dots'],
],]);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'border_dots',
'label' => __( 'Border', text_domain ),
'selector' => '{{WRAPPER}} .swiper-pagination span',
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'box_shadow_dots',
'label' => __( 'Box Shadow', text_domain ),
'selector' => '{{WRAPPER}} .swiper-pagination span',
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->end_controls_tab();
$this->start_controls_tab('style_active_tab_outline_dots', ['label' => __( 'Active', 'elementor' ),'condition' => [
'navigation' => ['both', 'dots'],
],]);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'border_dots_active',
'label' => __( 'Border', text_domain ),
'selector' => '{{WRAPPER}} .swiper-pagination span.swiper-pagination-bullet-active',
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'box_shadow_dots_active',
'label' => __( 'Box Shadow', text_domain ),
'selector' => '{{WRAPPER}} .swiper-pagination span.swiper-pagination-bullet-active',
'condition' => [
'navigation' => ['both', 'dots'],
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
}
protected function render(){
$settings = $this->get_settings();
$editor = Plugin::$instance->editor->is_edit_mode();
$id = $this->get_id();
$show_product_type = $settings['show_product_type'];
$title_tag = $settings['title_tag'];
$show_sale = $settings['show_sale'];
$text = $settings['text'];
$align_add_to_cart = $settings['align_add_to_cart'];
$product_type=$settings['product_type'];
$product_grid_columns = $settings['product_grid_columns'];
$enable_slider = $settings['enable_slider'];
$switch_image = $settings['switch_image'];
switch ($product_type) {
case "loop":
if ($editor) {
echo "<div class='woocommerce woocommerce-archive'>";
do_action( 'woocommerce_before_main_content' );
do_action( 'woocommerce_before_shop_loop' );
echo "<ul class='products flex flex-wrap $product_grid_columns'>";
$args = array(
'post_type' => 'product',
'posts_per_page' => 10,
);
$loop = new \WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
$this->Shop_Loop($settings,$show_product_type,$title_tag,$show_sale,$text,$align_add_to_cart,$switch_image);
endwhile; wp_reset_postdata();
echo "</ul>";
do_action( 'woocommerce_after_shop_loop' );
do_action( 'woocommerce_after_main_content' );
echo "</div>";
}else{
echo "<div class='woocommerce woocommerce-archive'>";
do_action( 'woocommerce_before_main_content' );
if ( woocommerce_product_loop() ) {
do_action( 'woocommerce_before_shop_loop' );
echo "<ul class='products flex flex-wrap $product_grid_columns'>";
if ( wc_get_loop_prop( 'total' ) ) {while ( have_posts() ) {the_post();
do_action( 'woocommerce_shop_loop' );
$this->Shop_Loop($settings,$show_product_type,$title_tag,$show_sale,$text,$align_add_to_cart,$switch_image);
}
}
echo "</ul>";
do_action( 'woocommerce_after_shop_loop' );
} else {
do_action( 'woocommerce_no_products_found' );
}
do_action( 'woocommerce_after_main_content' );
echo "</div>";
}
break;
case "product":
echo "<div class='woocommerce'>";
$exclude_products = ($settings['exclude_products']) ? explode(',', $settings['exclude_products']) : [];
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => $settings['products_count'],
'post_status' => 'publish',
'order' => $settings['products_order'],
'post_type' => 'product',
'post__not_in' => $exclude_products,
'paged'=> $paged,
);
if (!empty($settings['product_categories']) ) {
$args['tax_query'][] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $settings['product_categories'],
'post__not_in' => $exclude_products,
);
}
if ( 'yes' == $settings['hide_free'] ) {
$args['meta_query'][] = array(
'key' => '_price',
'value' => 0,
'compare' => '>',
'type' => 'DECIMAL',
);
}
$product_visibility_term_ids = wc_get_product_visibility_term_ids();
if ( 'yes' == $settings['hide_out_stock'] ) {
$args['tax_query'][] = array(
array(
'taxonomy' => 'product_visibility',
'field' => 'term_taxonomy_id',
'terms' => $product_visibility_term_ids['outofstock'],
'operator' => 'NOT IN',
),
); // WPCS: slow query ok.
}
switch ( $show_product_type ) {
case 'featured':
$args['tax_query'][] = array(
'taxonomy' => 'product_visibility',
'field' => 'term_taxonomy_id',
'terms' => $product_visibility_term_ids['featured'],
);
break;
case 'onsale':
$product_ids_on_sale = wc_get_product_ids_on_sale();
$product_ids_on_sale[] = 0;
$args['post__in'] = $product_ids_on_sale;
break;
}
switch ( $settings['orderby'] ) {
case 'price':
$args['meta_key'] = '_price'; // WPCS: slow query ok.
$args['orderby'] = 'meta_value_num';
break;
case 'rand':
$args['orderby'] = 'rand';
break;
case 'sales':
$args['meta_key'] = 'total_sales'; // WPCS: slow query ok.
$args['orderby'] = 'meta_value_num';
break;
default:
$args['orderby'] = 'date';
}
$query = new \WP_Query($args);
if($enable_slider == 'yes') {
$is_rtl = is_rtl();
$direction = $is_rtl ? 'rtl' : 'ltr';
$show_dots = ( in_array( $settings['navigation'], [ 'dots', 'both' ] ) );
$show_arrows = ( in_array( $settings['navigation'], [ 'arrows', 'both' ] ) );
$columns = $settings['slider_columns'];
$columns_tablet = $settings['column_tablet'];
$columns_mobile = $settings['column_mobile'];
$pause_on_hover = $settings['pause_on_hover'];
$infinite = $settings['infinite'];
$autoplay = $settings['autoplay'];
$centerMode = $settings['centerMode'];
$autoplay_speed = $settings['autoplay_speed'];
$effect = $settings['effect'];
$data_swiper = [
'columns' => absint($columns),
'columns_tablet' => absint($columns_tablet),
'columns_mobile_h' => $columns_tablet == 1 ? 1 : $columns_tablet - 1,
'columns_mobile' => absint($columns_mobile),
'autoplay' => ( 'yes' === $autoplay ),
'speed' => absint($autoplay_speed),
'pause_on_hover' => ( 'yes' === $pause_on_hover ),
'infinite' => ( 'yes' === $infinite ),
'centerMode' => ( 'yes' === $centerMode ),
'effect' => $effect,
];
if($effect == 'creative') {
$data_swiper['creative-type'] = $settings['creative_type'];
}
$this->add_render_attribute( 'slides', [
'data-swiper' => wp_json_encode( $data_swiper ),
] );
echo "<div id='slider-$id' id='products' class='products swiper tmt-slider-yes' dir='$direction' ". $this->get_render_attribute_string( 'slides' ) .">"
. "<div class='swiper-wrapper'>";
}else{echo "<div class='products flex flex-wrap'>";}
if ( $query->have_posts() ):while ( $query->have_posts() ):$query->the_post();
$this->Shop_Loop($settings,$show_product_type,$title_tag,$show_sale,$text,$align_add_to_cart,$switch_image);
endwhile;
if($enable_slider == 'yes') {
echo '</div>';
if($show_dots) {
echo "<div class='swiper-pagination flex align-items-center justify-content-center'></div>";
}
if($show_arrows) {
echo "<div class='tmt-sw-button swiper-button-prev'></div>"
. "<div class='tmt-sw-button swiper-button-next'></div>";
}
}
echo "</div>";
if (( 'yes' === $settings['show_pagination'] )) {
$GLOBALS['wp_query']->max_num_pages = $query->max_num_pages;
servin_the_posts_navigation(3);
};
endif;wp_reset_postdata();
echo "</div>";
break;
case "related":
echo "<div class='woocommerce'>";
global $post;
// get categories
$cat_terms = wp_get_post_terms( $post->ID, 'product_cat' );
foreach ( $cat_terms as $term ) $cats_array[] = $term->term_id;
$args = array(
'orderby' => 'rand',
'posts_per_page' => $settings['products_count'],
'post_status' => 'publish',
'post_type' => 'product',
'post__not_in' => array( $post->ID ),
'tax_query' => array(
'relation' => 'AND',
),
);
if(!empty($cat_terms)) {
$args['tax_query'] = array(
array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => $cats_array
),
);
}
$query = new \WP_Query($args);
if($enable_slider == 'yes') {
$is_rtl = is_rtl();
$direction = $is_rtl ? 'rtl' : 'ltr';
$show_dots = ( in_array( $settings['navigation'], [ 'dots', 'both' ] ) );
$show_arrows = ( in_array( $settings['navigation'], [ 'arrows', 'both' ] ) );
$columns = $settings['slider_columns'];
$columns_tablet = $settings['column_tablet'];
$columns_mobile = $settings['column_mobile'];
$pause_on_hover = $settings['pause_on_hover'];
$infinite = $settings['infinite'];
$autoplay = $settings['autoplay'];
$centerMode = $settings['centerMode'];
$autoplay_speed = $settings['autoplay_speed'];
$effect = $settings['effect'];
$data_swiper = [
'columns' => absint($columns),
'columns_tablet' => absint($columns_tablet),
'columns_mobile_h' => $columns_tablet == 1 ? 1 : $columns_tablet - 1,
'columns_mobile' => absint($columns_mobile),
'autoplay' => ( 'yes' === $autoplay ),
'speed' => absint($autoplay_speed),
'pause_on_hover' => ( 'yes' === $pause_on_hover ),
'infinite' => ( 'yes' === $infinite ),
'centerMode' => ( 'yes' === $centerMode ),
'effect' => $effect,
];
if($effect == 'creative') {
$data_swiper['creative-type'] = $settings['creative_type'];
}
$this->add_render_attribute( 'slides', [
'data-swiper' => wp_json_encode( $data_swiper ),
] );
echo "<div id='slider-$id' id='products' class='products swiper tmt-slider-yes' dir='$direction' ". $this->get_render_attribute_string( 'slides' ) .">"
. "<div class='swiper-wrapper'>";
}else{echo "<div class='products flex flex-wrap'>";}
if ( $query->have_posts() ):while ( $query->have_posts() ):$query->the_post();
$this->Shop_Loop($settings,$show_product_type,$title_tag,$show_sale,$text,$align_add_to_cart,$switch_image);
endwhile;
if($enable_slider == 'yes') {
echo '</div>';
if($show_dots) {
echo "<div class='swiper-pagination flex align-items-center justify-content-center'></div>";
}
if($show_arrows) {
echo "<div class='tmt-sw-button swiper-button-prev'></div>"
. "<div class='tmt-sw-button swiper-button-next'></div>";
}
}
echo "</div>";
endif;wp_reset_postdata();
echo "</div>";
break;
case "upsell":
if ($editor) {
$args = array(
'post_type' => 'product',
'posts_per_page' => $settings['products_count'],
'post_status' => 'publish',
);
$query = new \WP_Query($args);
echo "<div class='woocommerce'>";
if($enable_slider == 'yes') {
$is_rtl = is_rtl();
$direction = $is_rtl ? 'rtl' : 'ltr';
$show_dots = ( in_array( $settings['navigation'], [ 'dots', 'both' ] ) );
$show_arrows = ( in_array( $settings['navigation'], [ 'arrows', 'both' ] ) );
$columns = $settings['slider_columns'];
$columns_tablet = $settings['column_tablet'];
$columns_mobile = $settings['column_mobile'];
$pause_on_hover = $settings['pause_on_hover'];
$infinite = $settings['infinite'];
$autoplay = $settings['autoplay'];
$centerMode = $settings['centerMode'];
$autoplay_speed = $settings['autoplay_speed'];
$effect = $settings['effect'];
$data_swiper = [
'columns' => absint($columns),
'columns_tablet' => absint($columns_tablet),
'columns_mobile_h' => $columns_tablet == 1 ? 1 : $columns_tablet - 1,
'columns_mobile' => absint($columns_mobile),
'autoplay' => ( 'yes' === $autoplay ),
'speed' => absint($autoplay_speed),
'pause_on_hover' => ( 'yes' === $pause_on_hover ),
'infinite' => ( 'yes' === $infinite ),
'centerMode' => ( 'yes' === $centerMode ),
'effect' => $effect,
];
if($effect == 'creative') {
$data_swiper['creative-type'] = $settings['creative_type'];
}
$this->add_render_attribute( 'slides', [
'data-swiper' => wp_json_encode( $data_swiper ),
] );
echo "<div id='slider-$id' id='products' class='products swiper tmt-slider-yes' dir='$direction' ". $this->get_render_attribute_string( 'slides' ) .">"
. "<div class='swiper-wrapper'>";
}else{echo "<div class='products flex flex-wrap'>";}
if ( $query->have_posts() ):while ( $query->have_posts() ):$query->the_post();
$this->Shop_Loop($settings,$show_product_type,$title_tag,$show_sale,$text,$align_add_to_cart,$switch_image );
endwhile;
if($enable_slider == 'yes') {
echo '</div>';
if($show_dots) {
echo "<div class='swiper-pagination flex align-items-center justify-content-center'></div>";
}
if($show_arrows) {
echo "<div class='tmt-sw-button swiper-button-prev'></div>"
. "<div class='tmt-sw-button swiper-button-next'></div>";
}
}
echo "</div>";
endif;wp_reset_postdata();
echo "</div>";
} else {
echo "<div class='woocommerce'>";
if(is_product()) {
global $woocommerce, $product;
$upsells = $product->get_upsell_ids();
$prod_id = get_the_ID();
if ( sizeof( $upsells ) == 0 ) return;
$meta_query = $woocommerce->query->get_meta_query();
$args = array(
'posts_per_page' => $settings['products_count'],
'post_status' => 'publish',
'post_type' => 'product',
'ignore_sticky_posts' => 1,
'no_found_rows' => 1,
'post__in' => $upsells,
'post__not_in' => array( $prod_id ),
'meta_query' => $meta_query
);
$query = new \WP_Query($args);
if($enable_slider == 'yes') {
$is_rtl = is_rtl();
$direction = $is_rtl ? 'rtl' : 'ltr';
$show_dots = ( in_array( $settings['navigation'], [ 'dots', 'both' ] ) );
$show_arrows = ( in_array( $settings['navigation'], [ 'arrows', 'both' ] ) );
$columns = $settings['slider_columns'];
$columns_tablet = $settings['column_tablet'];
$columns_mobile = $settings['column_mobile'];
$pause_on_hover = $settings['pause_on_hover'];
$infinite = $settings['infinite'];
$autoplay = $settings['autoplay'];
$centerMode = $settings['centerMode'];
$autoplay_speed = $settings['autoplay_speed'];
$effect = $settings['effect'];
$data_swiper = [
'columns' => absint($columns),
'columns_tablet' => absint($columns_tablet),
'columns_mobile_h' => $columns_tablet == 1 ? 1 : $columns_tablet - 1,
'columns_mobile' => absint($columns_mobile),
'autoplay' => ( 'yes' === $autoplay ),
'speed' => absint($autoplay_speed),
'pause_on_hover' => ( 'yes' === $pause_on_hover ),
'infinite' => ( 'yes' === $infinite ),
'centerMode' => ( 'yes' === $centerMode ),
'effect' => $effect,
];
if($effect == 'creative') {
$data_swiper['creative-type'] = $settings['creative_type'];
}
$this->add_render_attribute( 'slides', [
'data-swiper' => wp_json_encode( $data_swiper ),
] );
echo "<div id='slider-$id' id='products' class='products swiper tmt-slider-yes' dir='$direction' ". $this->get_render_attribute_string( 'slides' ) .">"
. "<div class='swiper-wrapper'>";
}else{echo "<div class='products flex flex-wrap'>";}
if ( $query->have_posts() ):while ( $query->have_posts() ):$query->the_post();
global $product;
$id = $product->get_id();
$permalink = get_the_permalink();
if ( empty( $product ) || ! $product->is_visible() ) {
return;
}
$this->Shop_Loop($settings,$show_product_type,$title_tag,$show_sale,$text,$align_add_to_cart,$switch_image );
endwhile;
if($enable_slider == 'yes') {
echo '</div>';
if($show_dots) {
echo "<div class='swiper-pagination flex align-items-center justify-content-center'></div>";
}
if($show_arrows) {
echo "<div class='tmt-sw-button swiper-button-prev'></div>"
. "<div class='tmt-sw-button swiper-button-next'></div>";
}
}
echo "</div>";
endif;wp_reset_postdata();
echo "</div>";
}
}
break;
case "cross_sells":
global $product;
if ($editor) {
$args = array(
'post_type' => 'product',
'posts_per_page' => $settings['products_count'],
'post_status' => 'publish',
);
$query = new \WP_Query($args);
echo "<div class='woocommerce'>";
if($enable_slider == 'yes') {
$is_rtl = is_rtl();
$direction = $is_rtl ? 'rtl' : 'ltr';
$show_dots = ( in_array( $settings['navigation'], [ 'dots', 'both' ] ) );
$show_arrows = ( in_array( $settings['navigation'], [ 'arrows', 'both' ] ) );
$columns = $settings['slider_columns'];
$columns_tablet = $settings['column_tablet'];
$columns_mobile = $settings['column_mobile'];
$pause_on_hover = $settings['pause_on_hover'];
$infinite = $settings['infinite'];
$autoplay = $settings['autoplay'];
$centerMode = $settings['centerMode'];
$autoplay_speed = $settings['autoplay_speed'];
$effect = $settings['effect'];
$data_swiper = [
'columns' => absint($columns),
'columns_tablet' => absint($columns_tablet),
'columns_mobile_h' => $columns_tablet == 1 ? 1 : $columns_tablet - 1,
'columns_mobile' => absint($columns_mobile),
'autoplay' => ( 'yes' === $autoplay ),
'speed' => absint($autoplay_speed),
'pause_on_hover' => ( 'yes' === $pause_on_hover ),
'infinite' => ( 'yes' === $infinite ),
'centerMode' => ( 'yes' === $centerMode ),
'effect' => $effect,
];
if($effect == 'creative') {
$data_swiper['creative-type'] = $settings['creative_type'];
}
$this->add_render_attribute( 'slides', [
'data-swiper' => wp_json_encode( $data_swiper ),
] );
echo "<div id='slider-$id' id='products' class='products swiper tmt-slider-yes' dir='$direction' ". $this->get_render_attribute_string( 'slides' ) .">"
. "<div class='swiper-wrapper'>";
}else{echo "<div class='products flex flex-wrap'>";}
if ( $query->have_posts() ):while ( $query->have_posts() ):$query->the_post();
$this->Shop_Loop($settings,$show_product_type,$title_tag,$show_sale,$text,$align_add_to_cart,$switch_image );
endwhile;
if($enable_slider == 'yes') {
echo '</div>';
if($show_dots) {
echo "<div class='swiper-pagination flex align-items-center justify-content-center'></div>";
}
if($show_arrows) {
echo "<div class='tmt-sw-button swiper-button-prev'></div>"
. "<div class='tmt-sw-button swiper-button-next'></div>";
}
}
echo "</div>";
endif;wp_reset_postdata();
echo "</div>";
} else {
echo "<div class='woocommerce'>";
$crosssell_ids = get_post_meta( get_the_ID(), '_crosssell_ids' );
if(!empty($crosssell_ids)){
$crosssell_ids=$crosssell_ids[0];
$args = array(
'posts_per_page' => $settings['products_count'],
'post__in' => $crosssell_ids,
'post_status' => 'publish',
'post_type' => 'product',
);
$query = new \WP_Query($args);
if($enable_slider == 'yes') {
$is_rtl = is_rtl();
$direction = $is_rtl ? 'rtl' : 'ltr';
$show_dots = ( in_array( $settings['navigation'], [ 'dots', 'both' ] ) );
$show_arrows = ( in_array( $settings['navigation'], [ 'arrows', 'both' ] ) );
$columns = $settings['slider_columns'];
$columns_tablet = $settings['column_tablet'];
$columns_mobile = $settings['column_mobile'];
$pause_on_hover = $settings['pause_on_hover'];
$infinite = $settings['infinite'];
$autoplay = $settings['autoplay'];
$centerMode = $settings['centerMode'];
$autoplay_speed = $settings['autoplay_speed'];
$effect = $settings['effect'];
$data_swiper = [
'columns' => absint($columns),
'columns_tablet' => absint($columns_tablet),
'columns_mobile_h' => $columns_tablet == 1 ? 1 : $columns_tablet - 1,
'columns_mobile' => absint($columns_mobile),
'autoplay' => ( 'yes' === $autoplay ),
'speed' => absint($autoplay_speed),
'pause_on_hover' => ( 'yes' === $pause_on_hover ),
'infinite' => ( 'yes' === $infinite ),
'centerMode' => ( 'yes' === $centerMode ),
'effect' => $effect,
];
if($effect == 'creative') {
$data_swiper['creative-type'] = $settings['creative_type'];
}
$this->add_render_attribute( 'slides', [
'data-swiper' => wp_json_encode( $data_swiper ),
] );
echo "<div id='slider-$id' id='products' class='products swiper tmt-slider-yes' dir='$direction' ". $this->get_render_attribute_string( 'slides' ) .">"
. "<div class='swiper-wrapper'>";
}else{echo "<div class='products flex flex-wrap'>";}
if ( $query->have_posts() ):while ( $query->have_posts() ):$query->the_post();
$this->Shop_Loop($settings,$show_product_type,$title_tag,$show_sale,$text,$align_add_to_cart,$switch_image );
endwhile;
if($enable_slider == 'yes') {
echo '</div>';
if($show_dots) {
echo "<div class='swiper-pagination flex align-items-center justify-content-center'></div>";
}
if($show_arrows) {
echo "<div class='tmt-sw-button swiper-button-prev'></div>"
. "<div class='tmt-sw-button swiper-button-next'></div>";
}
}
echo "</div>";
endif;wp_reset_postdata();
echo "</div>";
}
break;
}
}
}
private function Shop_Loop($settings,$show_product_type,$title_tag,$show_sale,$text,$align_add_to_cart,$switch_image ){
global $product;
if ( empty( $product ) || ! $product->is_visible() ) {
return;
}
$link = get_the_permalink();
$title = get_the_title();
$id = $product->get_id();
echo '<li class="swiper-slide product">' ;
echo '<div class="content-shopping">';
echo '<article class="item">';
echo '<div class="pic-shop">';
echo '<div class="hover-shope">';
woocommerce_template_loop_product_thumbnail();
if($switch_image) {
if (!empty($product->get_gallery_image_ids()[0])) {echo "<div class='switch-image'>" . wp_get_attachment_image($product->get_gallery_image_ids()[0]) . "</div>";}
else {echo "<div class='switch-image'>" . wp_get_attachment_image($product->get_image_id()) . "</div>";}
}
echo '<div class="box-content flex flex-column justify-content-center align-items-center">';
echo "<a href='$link'><$title_tag class='title'>$title</$title_tag></a>";
echo '</div>';
if ($product->is_on_sale() && $show_sale == 'yes') {
echo "<div class='tmt-product-offer'>"
. "<span class='onsale'>". tmt_get_sell_price($id)."</span>"
. "</div>";
}
echo '</div>';
woocommerce_template_loop_price();
echo "<a href='$link' data-product-id='$id' class='basket-shop l-add-to-cart flex align-items-center justify-content-$align_add_to_cart'>"
. "$text"
. '</a>';
echo '</div>';
echo '</article>';
echo '</div>';
echo '</li>';
}
}
Plugin::instance()->widgets_manager->register( new TMT_Archive_Product );