first commit
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'calla_elated_map_woocommerce_meta' ) ) {
|
||||
function calla_elated_map_woocommerce_meta() {
|
||||
|
||||
$woocommerce_meta_box = calla_elated_create_meta_box(
|
||||
array(
|
||||
'scope' => array( 'product' ),
|
||||
'title' => esc_html__( 'Product Meta', 'calla' ),
|
||||
'name' => 'woo_product_meta'
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_create_meta_box_field(
|
||||
array(
|
||||
'name' => 'eltdf_product_featured_image_size',
|
||||
'type' => 'select',
|
||||
'label' => esc_html__( 'Dimensions for Product List Shortcode', 'calla' ),
|
||||
'description' => esc_html__( 'Choose image layout when it appears in Elated Product List - Masonry layout shortcode', 'calla' ),
|
||||
'options' => array(
|
||||
'' => esc_html__( 'Default', 'calla' ),
|
||||
'eltdf-woo-image-small' => esc_html__( 'Small', 'calla' ),
|
||||
'eltdf-woo-image-large-width' => esc_html__( 'Large Width', 'calla' ),
|
||||
'eltdf-woo-image-large-height' => esc_html__( 'Large Height', 'calla' ),
|
||||
'eltdf-woo-image-large-width-height' => esc_html__( 'Large Width Height', 'calla' )
|
||||
),
|
||||
'parent' => $woocommerce_meta_box
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_create_meta_box_field(
|
||||
array(
|
||||
'name' => 'eltdf_show_title_area_woo_meta',
|
||||
'type' => 'select',
|
||||
'default_value' => '',
|
||||
'label' => esc_html__( 'Show Title Area', 'calla' ),
|
||||
'description' => esc_html__( 'Disabling this option will turn off page title area', 'calla' ),
|
||||
'options' => calla_elated_get_yes_no_select_array(),
|
||||
'parent' => $woocommerce_meta_box
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_create_meta_box_field(
|
||||
array(
|
||||
'name' => 'eltdf_show_new_sign_woo_meta',
|
||||
'type' => 'yesno',
|
||||
'default_value' => 'no',
|
||||
'label' => esc_html__( 'Show New Sign', 'calla' ),
|
||||
'description' => esc_html__( 'Enabling this option will show new sign mark on product', 'calla' ),
|
||||
'parent' => $woocommerce_meta_box
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'calla_elated_meta_boxes_map', 'calla_elated_map_woocommerce_meta', 99 );
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_options_map' ) ) {
|
||||
|
||||
/**
|
||||
* Add Woocommerce options page
|
||||
*/
|
||||
function calla_elated_woocommerce_options_map() {
|
||||
|
||||
calla_elated_add_admin_page(
|
||||
array(
|
||||
'slug' => '_woocommerce_page',
|
||||
'title' => esc_html__( 'Woocommerce', 'calla' ),
|
||||
'icon' => 'fa fa-shopping-cart'
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Product List Settings
|
||||
*/
|
||||
$panel_product_list = calla_elated_add_admin_panel(
|
||||
array(
|
||||
'page' => '_woocommerce_page',
|
||||
'name' => 'panel_product_list',
|
||||
'title' => esc_html__( 'Product List', 'calla' )
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'eltdf_woo_product_list_columns',
|
||||
'label' => esc_html__( 'Product List Columns', 'calla' ),
|
||||
'default_value' => 'eltdf-woocommerce-columns-4',
|
||||
'description' => esc_html__( 'Choose number of columns for main shop page', 'calla' ),
|
||||
'options' => array(
|
||||
'eltdf-woocommerce-columns-3' => esc_html__( '3 Columns', 'calla' ),
|
||||
'eltdf-woocommerce-columns-4' => esc_html__( '4 Columns', 'calla' )
|
||||
),
|
||||
'parent' => $panel_product_list,
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'eltdf_woo_product_list_columns_space',
|
||||
'label' => esc_html__( 'Space Between Items', 'calla' ),
|
||||
'description' => esc_html__( 'Select space between items for product listing and related products on single product', 'calla' ),
|
||||
'default_value' => 'normal',
|
||||
'options' => calla_elated_get_space_between_items_array(),
|
||||
'parent' => $panel_product_list,
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'eltdf_woo_product_list_info_position',
|
||||
'label' => esc_html__( 'Product Info Position', 'calla' ),
|
||||
'default_value' => 'info_below_image',
|
||||
'description' => esc_html__( 'Select product info position for product listing and related products on single product', 'calla' ),
|
||||
'options' => array(
|
||||
'info_below_image' => esc_html__( 'Info Below Image', 'calla' ),
|
||||
'info_on_image_hover' => esc_html__( 'Info On Image Hover', 'calla' )
|
||||
),
|
||||
'parent' => $panel_product_list,
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'eltdf_woo_products_per_page',
|
||||
'label' => esc_html__( 'Number of products per page', 'calla' ),
|
||||
'description' => esc_html__( 'Set number of products on shop page', 'calla' ),
|
||||
'parent' => $panel_product_list,
|
||||
'args' => array(
|
||||
'col_width' => 3
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'eltdf_products_list_title_tag',
|
||||
'label' => esc_html__( 'Products Title Tag', 'calla' ),
|
||||
'default_value' => 'h5',
|
||||
'options' => calla_elated_get_title_tag(),
|
||||
'parent' => $panel_product_list,
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Single Product Settings
|
||||
*/
|
||||
$panel_single_product = calla_elated_add_admin_panel(
|
||||
array(
|
||||
'page' => '_woocommerce_page',
|
||||
'name' => 'panel_single_product',
|
||||
'title' => esc_html__( 'Single Product', 'calla' )
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'show_title_area_woo',
|
||||
'default_value' => '',
|
||||
'label' => esc_html__( 'Show Title Area', 'calla' ),
|
||||
'description' => esc_html__( 'Enabling this option will show title area on single post pages', 'calla' ),
|
||||
'parent' => $panel_single_product,
|
||||
'options' => calla_elated_get_yes_no_select_array(),
|
||||
'args' => array(
|
||||
'col_width' => 3
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'eltdf_single_product_title_tag',
|
||||
'default_value' => 'h2',
|
||||
'label' => esc_html__( 'Single Product Title Tag', 'calla' ),
|
||||
'options' => calla_elated_get_title_tag(),
|
||||
'parent' => $panel_single_product,
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'woo_number_of_thumb_images',
|
||||
'default_value' => '4',
|
||||
'label' => esc_html__( 'Number of Thumbnail Images per Row', 'calla' ),
|
||||
'options' => array(
|
||||
'4' => esc_html__( 'Four', 'calla' ),
|
||||
'3' => esc_html__( 'Three', 'calla' ),
|
||||
'2' => esc_html__( 'Two', 'calla' )
|
||||
),
|
||||
'parent' => $panel_single_product
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'woo_set_thumb_images_position',
|
||||
'default_value' => 'below-image',
|
||||
'label' => esc_html__( 'Set Thumbnail Images Position', 'calla' ),
|
||||
'options' => array(
|
||||
'below-image' => esc_html__( 'Below Featured Image', 'calla' ),
|
||||
'on-left-side' => esc_html__( 'On The Left Side Of Featured Image', 'calla' )
|
||||
),
|
||||
'parent' => $panel_single_product
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'woo_enable_single_product_zoom_image',
|
||||
'default_value' => 'no',
|
||||
'label' => esc_html__( 'Enable Zoom Maginfier', 'calla' ),
|
||||
'description' => esc_html__( 'Enabling this option will show magnifier image on featured image hover', 'calla' ),
|
||||
'parent' => $panel_single_product,
|
||||
'options' => calla_elated_get_yes_no_select_array( false ),
|
||||
'args' => array(
|
||||
'col_width' => 3
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'woo_set_single_images_behavior',
|
||||
'default_value' => 'pretty-photo',
|
||||
'label' => esc_html__( 'Set Images Behavior', 'calla' ),
|
||||
'options' => array(
|
||||
'pretty-photo' => esc_html__( 'Pretty Photo Lightbox', 'calla' ),
|
||||
'photo-swipe' => esc_html__( 'Photo Swipe Lightbox', 'calla' )
|
||||
),
|
||||
'parent' => $panel_single_product
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'eltdf_woo_related_products_columns',
|
||||
'label' => esc_html__( 'Related Products Columns', 'calla' ),
|
||||
'default_value' => 'eltdf-woocommerce-columns-4',
|
||||
'description' => esc_html__( 'Choose number of columns for related products on single product page', 'calla' ),
|
||||
'options' => array(
|
||||
'eltdf-woocommerce-columns-3' => esc_html__( '3 Columns', 'calla' ),
|
||||
'eltdf-woocommerce-columns-4' => esc_html__( '4 Columns', 'calla' )
|
||||
),
|
||||
'parent' => $panel_single_product,
|
||||
)
|
||||
);
|
||||
|
||||
do_action('calla_elated_woocommerce_additional_options_map');
|
||||
}
|
||||
|
||||
add_action( 'calla_elated_options_map', 'calla_elated_woocommerce_options_map', 21 );
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
var woocommerce = {};
|
||||
eltdf.modules.woocommerce = woocommerce;
|
||||
|
||||
woocommerce.eltdfOnDocumentReady = eltdfOnDocumentReady;
|
||||
woocommerce.eltdfOnWindowLoad = eltdfOnWindowLoad;
|
||||
woocommerce.eltdfOnWindowResize = eltdfOnWindowResize;
|
||||
|
||||
$(document).ready(eltdfOnDocumentReady);
|
||||
$(window).on('load', eltdfOnWindowLoad);
|
||||
$(window).resize(eltdfOnWindowResize);
|
||||
|
||||
/*
|
||||
All functions to be called on $(document).ready() should be in this function
|
||||
*/
|
||||
function eltdfOnDocumentReady() {
|
||||
eltdfInitQuantityButtons();
|
||||
eltdfInitSelect2();
|
||||
eltdfInitSingleProductLightbox();
|
||||
}
|
||||
|
||||
/*
|
||||
All functions to be called on $(window).load() should be in this function
|
||||
*/
|
||||
function eltdfOnWindowLoad() {
|
||||
eltdfInitProductListMasonryShortcode();
|
||||
}
|
||||
|
||||
/*
|
||||
All functions to be called on $(window).resize() should be in this function
|
||||
*/
|
||||
function eltdfOnWindowResize() {
|
||||
eltdfInitProductListMasonryShortcode();
|
||||
}
|
||||
|
||||
/*
|
||||
** Init quantity buttons to increase/decrease products for cart
|
||||
*/
|
||||
function eltdfInitQuantityButtons() {
|
||||
$(document).on('click', '.eltdf-quantity-minus, .eltdf-quantity-plus', function (e) {
|
||||
e.stopPropagation();
|
||||
|
||||
var button = $(this),
|
||||
inputField = button.siblings('.eltdf-quantity-input'),
|
||||
step = parseFloat(inputField.data('step')),
|
||||
max = parseFloat(inputField.data('max')),
|
||||
minus = false,
|
||||
inputValue = parseFloat(inputField.val()),
|
||||
newInputValue;
|
||||
|
||||
if (button.hasClass('eltdf-quantity-minus')) {
|
||||
minus = true;
|
||||
}
|
||||
|
||||
if (minus) {
|
||||
newInputValue = inputValue - step;
|
||||
if (newInputValue >= 1) {
|
||||
inputField.val(newInputValue);
|
||||
} else {
|
||||
inputField.val(0);
|
||||
}
|
||||
} else {
|
||||
newInputValue = inputValue + step;
|
||||
if (max === undefined) {
|
||||
inputField.val(newInputValue);
|
||||
} else {
|
||||
if (newInputValue >= max) {
|
||||
inputField.val(max);
|
||||
} else {
|
||||
inputField.val(newInputValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inputField.trigger('change');
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
** Init select2 script for select html dropdowns
|
||||
*/
|
||||
function eltdfInitSelect2() {
|
||||
var orderByDropDown = $('.woocommerce-ordering .orderby');
|
||||
if (orderByDropDown.length) {
|
||||
orderByDropDown.select2({
|
||||
minimumResultsForSearch: Infinity
|
||||
});
|
||||
}
|
||||
|
||||
var variableProducts = $('.eltdf-woocommerce-page .eltdf-content .variations td.value select');
|
||||
if (variableProducts.length) {
|
||||
variableProducts.select2();
|
||||
}
|
||||
|
||||
var shippingCountryCalc = $('#calc_shipping_country');
|
||||
if (shippingCountryCalc.length) {
|
||||
shippingCountryCalc.select2();
|
||||
}
|
||||
|
||||
var shippingStateCalc = $('.cart-collaterals .shipping select#calc_shipping_state');
|
||||
if (shippingStateCalc.length) {
|
||||
shippingStateCalc.select2();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Init Product Single Pretty Photo attributes
|
||||
*/
|
||||
function eltdfInitSingleProductLightbox() {
|
||||
var item = $('.eltdf-woo-single-page.eltdf-woo-single-has-pretty-photo .images .woocommerce-product-gallery__image');
|
||||
|
||||
if(item.length) {
|
||||
item.children('a').attr('data-rel', 'prettyPhoto[woo_single_pretty_photo]');
|
||||
|
||||
if (typeof eltdf.modules.common.eltdfPrettyPhoto === "function") {
|
||||
eltdf.modules.common.eltdfPrettyPhoto();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Init Product List Masonry Shortcode Layout
|
||||
*/
|
||||
function eltdfInitProductListMasonryShortcode() {
|
||||
var container = $('.eltdf-pl-holder.eltdf-masonry-layout .eltdf-pl-outer');
|
||||
|
||||
if (container.length) {
|
||||
container.each(function () {
|
||||
var thisContainer = $(this),
|
||||
size = thisContainer.find('.eltdf-pl-sizer').width();
|
||||
|
||||
thisContainer.waitForImages(function () {
|
||||
thisContainer.isotope({
|
||||
itemSelector: '.eltdf-pli',
|
||||
resizable: false,
|
||||
masonry: {
|
||||
columnWidth: '.eltdf-pl-sizer',
|
||||
gutter: '.eltdf-pl-gutter'
|
||||
}
|
||||
});
|
||||
|
||||
eltdfResizeWooCommerceMasonryLayoutItems(size, thisContainer);
|
||||
|
||||
thisContainer.isotope('layout').css('opacity', 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function eltdfResizeWooCommerceMasonryLayoutItems(size,container){
|
||||
if(container.find('.eltdf-woo-image-large-width').length || container.find('.eltdf-woo-image-large-height').length || container.find('.eltdf-woo-image-large-width-height').length) {
|
||||
var space_between_items = parseInt(container.find('.eltdf-pli').css('paddingLeft')),
|
||||
space_between_items_size = space_between_items !== undefined && space_between_items !== '' ? parseInt(space_between_items, 10) : 0,
|
||||
newSize = size - 2 * space_between_items_size,
|
||||
defaultMasonryItem = container.find('.eltdf-woo-image-small'),
|
||||
largeWidthMasonryItem = container.find('.eltdf-woo-image-large-width'),
|
||||
largeHeightMasonryItem = container.find('.eltdf-woo-image-large-height'),
|
||||
largeWidthHeightMasonryItem = container.find('.eltdf-woo-image-large-width-height');
|
||||
|
||||
if (eltdf.windowWidth > 680) {
|
||||
defaultMasonryItem.css('height', newSize);
|
||||
largeHeightMasonryItem.css('height', Math.round(2 * ( newSize + space_between_items_size )));
|
||||
largeWidthHeightMasonryItem.css('height', Math.round(2 * ( newSize + space_between_items_size )));
|
||||
largeWidthMasonryItem.css('height', newSize);
|
||||
} else {
|
||||
defaultMasonryItem.css('height', newSize);
|
||||
largeHeightMasonryItem.css('height', Math.round(2 * ( newSize + space_between_items_size )));
|
||||
largeWidthHeightMasonryItem.css('height', newSize);
|
||||
largeWidthMasonryItem.css('height', Math.round(newSize / 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/woocommerce-functions.php';
|
||||
|
||||
if ( calla_elated_is_woocommerce_installed() ) {
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/admin/options-map/woocommerce-map.php';
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/admin/meta-boxes/woocommerce-meta-boxes.php';
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/woocommerce-template-hooks.php';
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/woocommerce-config.php';
|
||||
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/shortcodes/shortcodes-functions.php';
|
||||
|
||||
foreach ( glob( ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/widgets/*/load.php' ) as $widget_load ) {
|
||||
include_once $widget_load;
|
||||
}
|
||||
|
||||
foreach ( glob( ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/plugins/*/load.php' ) as $plugin_load ) {
|
||||
include_once $plugin_load;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/plugins/yith-quick-view/yith-quick-view-conf.php';
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/plugins/yith-quick-view/yith-quick-view-functions.php';
|
||||
@@ -0,0 +1 @@
|
||||
<?php
|
||||
@@ -0,0 +1 @@
|
||||
<?php
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'calla_elated_add_product_info_shortcode' ) ) {
|
||||
function calla_elated_add_product_info_shortcode( $shortcodes_class_name ) {
|
||||
$shortcodes = array(
|
||||
'CallaCore\CPT\Shortcodes\ProductInfo\ProductInfo',
|
||||
);
|
||||
|
||||
$shortcodes_class_name = array_merge( $shortcodes_class_name, $shortcodes );
|
||||
|
||||
return $shortcodes_class_name;
|
||||
}
|
||||
|
||||
if ( calla_elated_core_plugin_installed() ) {
|
||||
add_filter( 'calla_core_filter_add_vc_shortcode', 'calla_elated_add_product_info_shortcode' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_add_product_info_into_shortcodes_list' ) ) {
|
||||
function calla_elated_add_product_info_into_shortcodes_list( $woocommerce_shortcodes ) {
|
||||
$woocommerce_shortcodes[] = 'eltdf_product_info';
|
||||
|
||||
return $woocommerce_shortcodes;
|
||||
}
|
||||
|
||||
add_filter( 'calla_elated_woocommerce_shortcodes_list', 'calla_elated_add_product_info_into_shortcodes_list' );
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/shortcodes/product-info/functions.php';
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/shortcodes/product-info/product-info.php';
|
||||
@@ -0,0 +1,529 @@
|
||||
<?php
|
||||
namespace CallaCore\CPT\Shortcodes\ProductInfo;
|
||||
|
||||
use CallaCore\Lib;
|
||||
|
||||
class ProductInfo implements Lib\ShortcodeInterface {
|
||||
private $base;
|
||||
|
||||
function __construct() {
|
||||
$this->base = 'eltdf_product_info';
|
||||
|
||||
add_action('vc_before_init', array($this,'vcMap'));
|
||||
|
||||
//Product id filter
|
||||
add_filter( 'vc_autocomplete_eltdf_product_info_product_id_callback', array( &$this, 'productIdAutocompleteSuggester', ), 10, 1 );
|
||||
|
||||
//Product id render
|
||||
add_filter( 'vc_autocomplete_eltdf_product_info_product_id_render', array( &$this, 'productIdAutocompleteRender', ), 10, 1 );
|
||||
}
|
||||
|
||||
public function getBase() {
|
||||
return $this->base;
|
||||
}
|
||||
|
||||
public function vcMap() {
|
||||
if(function_exists('vc_map')) {
|
||||
vc_map(
|
||||
array(
|
||||
'name' => esc_html__( 'Elated Product Info', 'calla' ),
|
||||
'base' => $this->getBase(),
|
||||
'category' => esc_html__( 'by ELATED', 'calla' ),
|
||||
'icon' => 'icon-wpb-product-info extended-custom-icon',
|
||||
'allowed_container_element' => 'vc_row',
|
||||
'params' => array(
|
||||
array(
|
||||
'type' => 'autocomplete',
|
||||
'param_name' => 'product_id',
|
||||
'heading' => esc_html__( 'Selected Product', 'calla' ),
|
||||
'settings' => array(
|
||||
'sortable' => true,
|
||||
'unique_values' => true
|
||||
),
|
||||
'admin_label' => true,
|
||||
'save_always' => true,
|
||||
'description' => esc_html__( 'If you left this field empty then product ID will be of the current page', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'product_info_type',
|
||||
'heading' => esc_html__( 'Product Info Type', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Title', 'calla' ) => 'title',
|
||||
esc_html__( 'Featured Image', 'calla' ) => 'featured_image',
|
||||
esc_html__( 'Category', 'calla' ) => 'category',
|
||||
esc_html__( 'Excerpt', 'calla' ) => 'excerpt',
|
||||
esc_html__( 'Price', 'calla' ) => 'price',
|
||||
esc_html__( 'Rating', 'calla' ) => 'rating',
|
||||
esc_html__( 'Add To Cart', 'calla' ) => 'add_to_cart',
|
||||
esc_html__( 'Tag', 'calla' ) => 'tag',
|
||||
esc_html__( 'Author', 'calla' ) => 'author',
|
||||
esc_html__( 'Date', 'calla' ) => 'date',
|
||||
),
|
||||
'admin_label' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'colorpicker',
|
||||
'param_name' => 'product_info_color',
|
||||
'heading' => esc_html__( 'Product Info Color', 'calla' ),
|
||||
'dependency' => array( 'element' => 'product_info_type', 'value' => array( 'title', 'category', 'excerpt', 'price', 'rating', 'tag', 'author', 'date' ) ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'title_tag',
|
||||
'heading' => esc_html__( 'Title Tag', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_title_tag( true, array( 'p' => 'p' ) ) ),
|
||||
'description' => esc_html__( 'Set title tag for product title element', 'calla' ),
|
||||
'dependency' => array( 'element' => 'product_info_type', 'value' => array( 'title' ) ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'featured_image_size',
|
||||
'heading' => esc_html__( 'Featured Image Proportions', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Default', 'calla' ) => '',
|
||||
esc_html__( 'Original', 'calla' ) => 'full',
|
||||
esc_html__( 'Square', 'calla' ) => 'calla_elated_square',
|
||||
esc_html__( 'Landscape', 'calla' ) => 'calla_elated_landscape',
|
||||
esc_html__( 'Portrait', 'calla' ) => 'calla_elated_portrait',
|
||||
esc_html__( 'Medium', 'calla' ) => 'medium',
|
||||
esc_html__( 'Large', 'calla' ) => 'large',
|
||||
esc_html__( 'Shop Single', 'calla' ) => 'woocommerce_single',
|
||||
esc_html__( 'Shop Thumbnail', 'calla' ) => 'woocommerce_thumbnail'
|
||||
),
|
||||
'dependency' => array( 'element' => 'product_info_type', 'value' => array( 'featured_image' ) )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'category_tag',
|
||||
'heading' => esc_html__( 'Category Tag', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_title_tag( true ) ),
|
||||
'description' => esc_html__( 'Set category tag for product category element', 'calla' ),
|
||||
'dependency' => array( 'element' => 'product_info_type', 'value' => array( 'category' ) ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'add_to_cart_skin',
|
||||
'heading' => esc_html__( 'Add To Cart Skin', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Default', 'calla' ) => '',
|
||||
esc_html__( 'White', 'calla' ) => 'white',
|
||||
esc_html__( 'Dark', 'calla' ) => 'dark'
|
||||
),
|
||||
'dependency' => array( 'element' => 'product_info_type', 'value' => array( 'add_to_cart' ) )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'add_to_cart_size',
|
||||
'heading' => esc_html__( 'Add To Cart Size', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Default', 'calla' ) => '',
|
||||
esc_html__( 'Small', 'calla' ) => 'small',
|
||||
esc_html__( 'Medium', 'calla' ) => 'medium',
|
||||
esc_html__( 'Large', 'calla' ) => 'large'
|
||||
),
|
||||
'dependency' => array( 'element' => 'product_info_type', 'value' => array( 'calla' ) ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function render($atts, $content = null) {
|
||||
$args = array(
|
||||
'product_id' => '',
|
||||
'product_info_type' => 'title',
|
||||
'product_info_color' => '',
|
||||
'title_tag' => 'h2',
|
||||
'featured_image_size' => 'full',
|
||||
'category_tag' => '',
|
||||
'add_to_cart_skin' => '',
|
||||
'add_to_cart_size' => ''
|
||||
);
|
||||
$params = shortcode_atts($args, $atts);
|
||||
extract($params);
|
||||
|
||||
$params['product_id'] = !empty($params['product_id']) ? $params['product_id'] : get_the_ID();
|
||||
$params['title_tag'] = !empty($params['title_tag']) ? $params['title_tag'] : $args['title_tag'];
|
||||
$params['category_tag'] = !empty($params['category_tag']) ? $params['category_tag'] : $args['category_tag'];
|
||||
|
||||
$params['product_info_style'] = $this->getProductInfoStyle($params);
|
||||
|
||||
$html = '';
|
||||
$html .= '<div class="eltdf-product-info">';
|
||||
|
||||
switch ($product_info_type) {
|
||||
case 'title':
|
||||
$html .= $this->getItemTitleHtml($params);
|
||||
break;
|
||||
case 'featured_image':
|
||||
$html .= $this->getItemFeaturedImageHtml($params);
|
||||
break;
|
||||
case 'category':
|
||||
$html .= $this->getItemCategoryHtml($params);
|
||||
break;
|
||||
case 'excerpt':
|
||||
$html .= $this->getItemExcerptHtml($params);
|
||||
break;
|
||||
case 'price':
|
||||
$html .= $this->getItemPriceHtml($params);
|
||||
break;
|
||||
case 'rating':
|
||||
$html .= $this->getItemRatingHtml($params);
|
||||
break;
|
||||
case 'add_to_cart':
|
||||
$html .= $this->getItemAddToCartHtml($params);
|
||||
break;
|
||||
case 'tag':
|
||||
$html .= $this->getItemTagHtml($params);
|
||||
break;
|
||||
case 'author':
|
||||
$html .= $this->getItemAuthorHtml($params);
|
||||
break;
|
||||
case 'date':
|
||||
$html .= $this->getItemDateHtml($params);
|
||||
break;
|
||||
default:
|
||||
$html .= $this->getItemTitleHtml($params);
|
||||
break;
|
||||
}
|
||||
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return product info styles
|
||||
*
|
||||
* @param $params
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getProductInfoStyle( $params ) {
|
||||
$styles = array();
|
||||
|
||||
if ( ! empty( $params['product_info_color'] ) ) {
|
||||
$styles[] = 'color: ' . $params['product_info_color'];
|
||||
}
|
||||
|
||||
return $styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates product title html based on id
|
||||
*
|
||||
* @param $params
|
||||
*
|
||||
* @return html
|
||||
*/
|
||||
public function getItemTitleHtml( $params ) {
|
||||
$html = '';
|
||||
$product_id = $params['product_id'];
|
||||
$title = get_the_title( $product_id );
|
||||
$title_tag = $params['title_tag'];
|
||||
$product_info_style = $params['product_info_style'];
|
||||
|
||||
if ( ! empty( $title ) ) {
|
||||
$html = '<' . esc_attr( $title_tag ) . ' itemprop="name" class="eltdf-pi-title entry-title" ' . calla_elated_get_inline_style( $product_info_style ) . '>';
|
||||
$html .= '<a itemprop="url" href="' . esc_url( get_the_permalink( $product_id ) ) . '">' . esc_html( $title ) . '</a>';
|
||||
$html .= '</' . esc_attr( $title_tag ) . '>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates product featured image html based on id
|
||||
*
|
||||
* @param $params
|
||||
*
|
||||
* @return html
|
||||
*/
|
||||
public function getItemFeaturedImageHtml( $params ) {
|
||||
$html = '';
|
||||
$product_id = $params['product_id'];
|
||||
$featured_image_size = ! empty( $params['featured_image_size'] ) ? $params['featured_image_size'] : 'full';
|
||||
$featured_image = get_the_post_thumbnail( $product_id, $featured_image_size );
|
||||
|
||||
if ( ! empty( $featured_image ) ) {
|
||||
$html = '<a itemprop="url" class="eltdf-pi-image" href="' . esc_url( get_the_permalink( $product_id ) ) . '">' . $featured_image . '</a>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates product categories html based on id
|
||||
*
|
||||
* @param $params
|
||||
*
|
||||
* @return html
|
||||
*/
|
||||
public function getItemCategoryHtml( $params ) {
|
||||
$html = '';
|
||||
$product_id = $params['product_id'];
|
||||
$categories = wp_get_post_terms( $product_id, 'product_cat' );
|
||||
$product_info_style = $params['product_info_style'];
|
||||
|
||||
if ( ! empty( $categories ) ) {
|
||||
$html .= '<div class="eltdf-pi-category">';
|
||||
foreach ( $categories as $cat ) {
|
||||
if ( ! empty( $params['category_tag'] ) ) {
|
||||
$html .= '<' . esc_attr( $params['category_tag'] ) . ' ' . calla_elated_get_inline_style( $product_info_style ) . '>';
|
||||
$html .= '<a itemprop="url" class="eltdf-pi-category-item" href="' . esc_url( get_term_link( $cat->term_id ) ) . '">' . esc_html( $cat->name ) . '</a>';
|
||||
$html .= '</' . esc_attr( $params['category_tag'] ) . '>';
|
||||
} else {
|
||||
$html .= '<a itemprop="url" class="eltdf-pi-category-item" href="' . esc_url( get_term_link( $cat->term_id ) ) . '" ' . calla_elated_get_inline_style( $product_info_style ) . '>' . esc_html( $cat->name ) . '</a>';
|
||||
}
|
||||
}
|
||||
$html .= '</div>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates product excerpt html based on id
|
||||
*
|
||||
* @param $params
|
||||
*
|
||||
* @return html
|
||||
*/
|
||||
public function getItemExcerptHtml( $params ) {
|
||||
$html = '';
|
||||
$product_id = $params['product_id'];
|
||||
$excerpt = get_the_excerpt( $product_id );
|
||||
$product_info_style = $params['product_info_style'];
|
||||
|
||||
if ( ! empty( $excerpt ) ) {
|
||||
$html = '<div class="eltdf-pi-excerpt"><p itemprop="description" class="eltdf-pi-excerpt-item" ' . calla_elated_get_inline_style( $product_info_style ) . '>' . esc_html( $excerpt ) . '</p></div>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates product price html based on id
|
||||
*
|
||||
* @param $params
|
||||
*
|
||||
* @return html
|
||||
*/
|
||||
public function getItemPriceHtml( $params ) {
|
||||
$html = '';
|
||||
$product_id = $params['product_id'];
|
||||
$product = wc_get_product( $product_id );
|
||||
$product_info_style = $params['product_info_style'];
|
||||
|
||||
if ( $price_html = $product->get_price_html() ) {
|
||||
$html = '<div class="eltdf-pi-price" ' . calla_elated_get_inline_style( $product_info_style ) . '>' . $price_html . '</div>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates product rating html based on id
|
||||
*
|
||||
* @param $params
|
||||
*
|
||||
* @return html
|
||||
*/
|
||||
public function getItemRatingHtml( $params ) {
|
||||
$html = '';
|
||||
$product_id = $params['product_id'];
|
||||
$product = wc_get_product( $product_id );
|
||||
$product_info_style = $params['product_info_style'];
|
||||
|
||||
if ( get_option( 'woocommerce_enable_review_rating' ) !== 'no' ) {
|
||||
$average = $product->get_average_rating();
|
||||
|
||||
$html = '<div class="eltdf-pi-rating" title="' . sprintf( esc_attr__( "Rated %s out of 5", "calla" ), $average ) . '" ' . calla_elated_get_inline_style( $product_info_style ) . '><span style="width:' . ( ( $average / 5 ) * 100 ) . '%"></span></div>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates product add to cart html based on id
|
||||
*
|
||||
* @param $params
|
||||
*
|
||||
* @return html
|
||||
*/
|
||||
public function getItemAddToCartHtml( $params ) {
|
||||
$product_id = $params['product_id'];
|
||||
$product = wc_get_product( $product_id );
|
||||
|
||||
if ( ! $product->is_in_stock() ) {
|
||||
$button_classes = 'button ajax_add_to_cart eltdf-btn eltdf-btn-solid';
|
||||
} else if ( $product->get_type() === 'variable' ) {
|
||||
$button_classes = 'button product_type_variable add_to_cart_button eltdf-btn eltdf-btn-solid';
|
||||
} else if ( $product->get_type() === 'external' ) {
|
||||
$button_classes = 'button product_type_external eltdf-btn eltdf-btn-solid';
|
||||
} else {
|
||||
$button_classes = 'button add_to_cart_button ajax_add_to_cart eltdf-btn eltdf-btn-solid';
|
||||
}
|
||||
|
||||
if ( ! empty( $params['add_to_cart_skin'] ) ) {
|
||||
$button_classes .= ' eltdf-' . $params['add_to_cart_skin'] . '-skin eltdf-btn-custom-hover-color eltdf-btn-custom-hover-bg eltdf-btn-custom-border-hover';
|
||||
}
|
||||
|
||||
if ( ! empty( $params['add_to_cart_size'] ) ) {
|
||||
$button_classes .= ' eltdf-btn-' . $params['add_to_cart_size'];
|
||||
}
|
||||
|
||||
$html = '<div class="eltdf-pi-add-to-cart">';
|
||||
$html .= apply_filters( 'calla_elated_product_info_add_to_cart_link',
|
||||
sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">%s</a>',
|
||||
esc_url( $product->add_to_cart_url() ),
|
||||
esc_attr( isset( $quantity ) ? $quantity : 1 ),
|
||||
esc_attr( $product_id ),
|
||||
esc_attr( $product->get_sku() ),
|
||||
esc_attr( $button_classes ),
|
||||
esc_html( $product->add_to_cart_text() )
|
||||
),
|
||||
$product );
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates product tags html based on id
|
||||
*
|
||||
* @param $params
|
||||
*
|
||||
* @return html
|
||||
*/
|
||||
public function getItemTagHtml( $params ) {
|
||||
$html = '';
|
||||
$product_id = $params['product_id'];
|
||||
$tags = wp_get_post_terms( $product_id, 'product_tag' );
|
||||
$product_info_style = $params['product_info_style'];
|
||||
|
||||
if ( ! empty( $tags ) ) {
|
||||
$html = '<div class="eltdf-pi-tag">';
|
||||
foreach ( $tags as $tag ) {
|
||||
$html .= '<a itemprop="url" class="eltdf-pi-tag-item" href="' . esc_url( get_term_link( $tag->term_id ) ) . '" ' . calla_elated_get_inline_style( $product_info_style ) . '>' . esc_html( $tag->name ) . '</a>';
|
||||
}
|
||||
$html .= '</div>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates product authors html based on id
|
||||
*
|
||||
* @param $params
|
||||
*
|
||||
* @return html
|
||||
*/
|
||||
public function getItemAuthorHtml( $params ) {
|
||||
$html = '';
|
||||
$product_id = $params['product_id'];
|
||||
$product_post = get_post( $product_id );
|
||||
$autor_id = $product_post->post_author;
|
||||
$author = get_the_author_meta( 'display_name', $autor_id );
|
||||
$product_info_style = $params['product_info_style'];
|
||||
|
||||
if ( ! empty( $author ) ) {
|
||||
$html = '<div class="eltdf-pi-author" ' . calla_elated_get_inline_style( $product_info_style ) . '>' . esc_html( $author ) . '</div>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates product date html based on id
|
||||
*
|
||||
* @param $params
|
||||
*
|
||||
* @return html
|
||||
*/
|
||||
public function getItemDateHtml( $params ) {
|
||||
$html = '';
|
||||
$product_id = $params['product_id'];
|
||||
$date = get_the_time( get_option( 'date_format' ), $product_id );
|
||||
$product_info_style = $params['product_info_style'];
|
||||
|
||||
if ( ! empty( $date ) ) {
|
||||
$html = '<div class="eltdf-pi-date" ' . calla_elated_get_inline_style( $product_info_style ) . '>' . esc_html( $date ) . '</div>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter product by ID or Title
|
||||
*
|
||||
* @param $query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function productIdAutocompleteSuggester( $query ) {
|
||||
global $wpdb;
|
||||
$product_id = (int) $query;
|
||||
$post_meta_infos = $wpdb->get_results( $wpdb->prepare( "SELECT ID AS id, post_title AS title
|
||||
FROM {$wpdb->posts}
|
||||
WHERE post_type = 'product' AND ( ID = '%d' OR post_title LIKE '%%%s%%' )", $product_id > 0 ? $product_id : - 1, stripslashes( $query ), stripslashes( $query ) ), ARRAY_A );
|
||||
|
||||
$results = array();
|
||||
if ( is_array( $post_meta_infos ) && ! empty( $post_meta_infos ) ) {
|
||||
foreach ( $post_meta_infos as $value ) {
|
||||
$data = array();
|
||||
$data['value'] = $value['id'];
|
||||
$data['label'] = esc_html__( 'Id', 'calla' ) . ': ' . $value['id'] . ( ( strlen( $value['title'] ) > 0 ) ? ' - ' . esc_html__( 'Title', 'calla' ) . ': ' . $value['title'] : '' );
|
||||
$results[] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Find product by id
|
||||
* @since 4.4
|
||||
*
|
||||
* @param $query
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
public function productIdAutocompleteRender( $query ) {
|
||||
$query = trim( $query['value'] ); // get value from requested
|
||||
if ( ! empty( $query ) ) {
|
||||
|
||||
$product = get_post( (int) $query );
|
||||
if ( ! is_wp_error( $product ) ) {
|
||||
|
||||
$product_id = $product->ID;
|
||||
$product_title = $product->post_title;
|
||||
|
||||
$product_title_display = '';
|
||||
if ( ! empty( $product_title ) ) {
|
||||
$product_title_display = ' - ' . esc_html__( 'Title', 'calla' ) . ': ' . $product_title;
|
||||
}
|
||||
|
||||
$product_id_display = esc_html__( 'Id', 'calla' ) . ': ' . $product_id;
|
||||
|
||||
$data = array();
|
||||
$data['value'] = $product_id;
|
||||
$data['label'] = $product_id_display . $product_title_display;
|
||||
|
||||
return ! empty( $data ) ? $data : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'calla_elated_add_product_list_carousel_shortcode' ) ) {
|
||||
function calla_elated_add_product_list_carousel_shortcode( $shortcodes_class_name ) {
|
||||
$shortcodes = array(
|
||||
'CallaCore\CPT\Shortcodes\ProductListCarousel\ProductListCarousel',
|
||||
);
|
||||
|
||||
$shortcodes_class_name = array_merge( $shortcodes_class_name, $shortcodes );
|
||||
|
||||
return $shortcodes_class_name;
|
||||
}
|
||||
|
||||
if ( calla_elated_core_plugin_installed() ) {
|
||||
add_filter( 'calla_core_filter_add_vc_shortcode', 'calla_elated_add_product_list_carousel_shortcode' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_add_product_list_carousel_into_shortcodes_list' ) ) {
|
||||
function calla_elated_add_product_list_carousel_into_shortcodes_list( $woocommerce_shortcodes ) {
|
||||
$woocommerce_shortcodes[] = 'eltdf_product_list_carousel';
|
||||
|
||||
return $woocommerce_shortcodes;
|
||||
}
|
||||
|
||||
add_filter( 'calla_elated_woocommerce_shortcodes_list', 'calla_elated_add_product_list_carousel_into_shortcodes_list' );
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/shortcodes/product-list-carousel/functions.php';
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/shortcodes/product-list-carousel/product-list-carousel.php';
|
||||
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
|
||||
namespace CallaCore\CPT\Shortcodes\ProductListCarousel;
|
||||
|
||||
use CallaCore\Lib;
|
||||
|
||||
class ProductListCarousel implements Lib\ShortcodeInterface {
|
||||
private $base;
|
||||
|
||||
function __construct() {
|
||||
$this->base = 'eltdf_product_list_carousel';
|
||||
|
||||
add_action( 'vc_before_init', array( $this, 'vcMap' ) );
|
||||
}
|
||||
|
||||
public function getBase() {
|
||||
return $this->base;
|
||||
}
|
||||
|
||||
public function vcMap() {
|
||||
if ( function_exists( 'vc_map' ) ) {
|
||||
vc_map(
|
||||
array(
|
||||
'name' => esc_html__( 'Elated Product List - Carousel', 'calla' ),
|
||||
'base' => $this->base,
|
||||
'icon' => 'icon-wpb-product-list-carousel extended-custom-icon',
|
||||
'category' => esc_html__( 'by ELATED', 'calla' ),
|
||||
'allowed_container_element' => 'vc_row',
|
||||
'params' => array(
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'type',
|
||||
'heading' => esc_html__( 'Type', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Standard', 'calla' ) => 'standard',
|
||||
esc_html__( 'Simple', 'calla' ) => 'simple'
|
||||
),
|
||||
'save_always' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'param_name' => 'number_of_posts',
|
||||
'heading' => esc_html__( 'Number of Products', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'space_between_items',
|
||||
'heading' => esc_html__( 'Space Between Items', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_space_between_items_array() ),
|
||||
'save_always' => true,
|
||||
'dependency' => array( 'element' => 'type', 'value' => array( 'standard' ) )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'orderby',
|
||||
'heading' => esc_html__( 'Order By', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_query_order_by_array( false, array( 'on-sale' => esc_html__( 'On Sale', 'calla' ) ) ) ),
|
||||
'save_always' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'order',
|
||||
'heading' => esc_html__( 'Order', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_query_order_array() ),
|
||||
'save_always' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'taxonomy_to_display',
|
||||
'heading' => esc_html__( 'Choose Sorting Taxonomy', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Category', 'calla' ) => 'category',
|
||||
esc_html__( 'Tag', 'calla' ) => 'tag',
|
||||
esc_html__( 'Id', 'calla' ) => 'id'
|
||||
),
|
||||
'save_always' => true,
|
||||
'description' => esc_html__( 'If you would like to display only certain products, this is where you can select the criteria by which you would like to choose which products to display', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'param_name' => 'taxonomy_values',
|
||||
'heading' => esc_html__( 'Enter Taxonomy Values', 'calla' ),
|
||||
'description' => esc_html__( 'Separate values (category slugs, tags, or post IDs) with a comma', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'heading' => esc_html__( 'Image Proportions', 'calla' ),
|
||||
'param_name' => 'image_size',
|
||||
'value' => array(
|
||||
esc_html__( 'Default', 'calla' ) => '',
|
||||
esc_html__( 'Original', 'calla' ) => 'full',
|
||||
esc_html__( 'Square', 'calla' ) => 'square',
|
||||
esc_html__( 'Landscape', 'calla' ) => 'landscape',
|
||||
esc_html__( 'Portrait', 'calla' ) => 'portrait',
|
||||
esc_html__( 'Medium', 'calla' ) => 'medium',
|
||||
esc_html__( 'Large', 'calla' ) => 'large',
|
||||
esc_html__( 'Shop Single', 'calla' ) => 'woocommerce_single',
|
||||
esc_html__( 'Shop Thumbnail', 'calla' ) => 'woocommerce_thumbnail'
|
||||
),
|
||||
'save_always' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'number_of_visible_items',
|
||||
'heading' => esc_html__( 'Number Of Visible Items', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'One', 'calla' ) => '1',
|
||||
esc_html__( 'Two', 'calla' ) => '2',
|
||||
esc_html__( 'Three', 'calla' ) => '3',
|
||||
esc_html__( 'Four', 'calla' ) => '4',
|
||||
esc_html__( 'Five', 'calla' ) => '5',
|
||||
esc_html__( 'Six', 'calla' ) => '6'
|
||||
),
|
||||
'save_always' => true,
|
||||
'group' => esc_html__( 'Slider Settings', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'slider_loop',
|
||||
'heading' => esc_html__( 'Enable Slider Loop', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) ),
|
||||
'save_always' => true,
|
||||
'group' => esc_html__( 'Slider Settings', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'slider_autoplay',
|
||||
'heading' => esc_html__( 'Enable Slider Autoplay', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) ),
|
||||
'save_always' => true,
|
||||
'group' => esc_html__( 'Slider Settings', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'param_name' => 'slider_speed',
|
||||
'heading' => esc_html__( 'Slide Duration', 'calla' ),
|
||||
'description' => esc_html__( 'Default value is 5000 (ms)', 'calla' ),
|
||||
'group' => esc_html__( 'Slider Settings', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'param_name' => 'slider_speed_animation',
|
||||
'heading' => esc_html__( 'Slide Animation Duration', 'calla' ),
|
||||
'description' => esc_html__( 'Speed of slide animation in milliseconds. Default value is 600.', 'calla' ),
|
||||
'group' => esc_html__( 'Slider Settings', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'slider_navigation',
|
||||
'heading' => esc_html__( 'Enable Slider Navigation Arrows', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) ),
|
||||
'save_always' => true,
|
||||
'group' => esc_html__( 'Slider Settings', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'slider_navigation_skin',
|
||||
'heading' => esc_html__( 'Slider Navigation Skin', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Default', 'calla' ) => 'default',
|
||||
esc_html__( 'Light', 'calla' ) => 'light'
|
||||
),
|
||||
'dependency' => array( 'element' => 'slider_navigation', 'value' => array( 'yes' ) ),
|
||||
'group' => esc_html__( 'Slider Settings', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'slider_navigation_pos',
|
||||
'heading' => esc_html__( 'Slider Navigation Position', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Before Carousel', 'calla' ) => 'before-slider',
|
||||
esc_html__( 'Inside Carousel', 'calla' ) => 'inside-slider'
|
||||
),
|
||||
'dependency' => array( 'element' => 'slider_navigation', 'value' => array( 'yes' ) ),
|
||||
'group' => esc_html__( 'Slider Settings', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'slider_pagination',
|
||||
'heading' => esc_html__( 'Enable Slider Pagination', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) ),
|
||||
'save_always' => true,
|
||||
'group' => esc_html__( 'Slider Settings', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'slider_pagination_skin',
|
||||
'heading' => esc_html__( 'Slider Pagination Skin', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Default', 'calla' ) => 'default',
|
||||
esc_html__( 'Light', 'calla' ) => 'light'
|
||||
),
|
||||
'dependency' => array( 'element' => 'slider_pagination', 'value' => array( 'yes' ) ),
|
||||
'group' => esc_html__( 'Slider Settings', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'slider_pagination_pos',
|
||||
'heading' => esc_html__( 'Slider Pagination Position', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Below Carousel', 'calla' ) => 'bellow-slider',
|
||||
esc_html__( 'Inside Carousel', 'calla' ) => 'inside-slider'
|
||||
),
|
||||
'dependency' => array( 'element' => 'slider_pagination', 'value' => array( 'yes' ) ),
|
||||
'group' => esc_html__( 'Slider Settings', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'display_title',
|
||||
'heading' => esc_html__( 'Display Title', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) ),
|
||||
'group' => esc_html__( 'Product Info', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'title_tag',
|
||||
'heading' => esc_html__( 'Title Tag', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_title_tag( true ) ),
|
||||
'dependency' => array( 'element' => 'display_title', 'value' => array( 'yes' ) ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'title_transform',
|
||||
'heading' => esc_html__( 'Title Text Transform', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_text_transform_array( true ) ),
|
||||
'dependency' => array( 'element' => 'display_title', 'value' => array( 'yes' ) ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'display_category',
|
||||
'heading' => esc_html__( 'Display Category', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false ) ),
|
||||
'group' => esc_html__( 'Product Info', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'display_rating',
|
||||
'heading' => esc_html__( 'Display Rating', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) ),
|
||||
'group' => esc_html__( 'Product Info', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'display_price',
|
||||
'heading' => esc_html__( 'Display Price', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) ),
|
||||
'group' => esc_html__( 'Product Info', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'display_button',
|
||||
'heading' => esc_html__( 'Display Button', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) ),
|
||||
'group' => esc_html__( 'Product Info', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'button_skin',
|
||||
'heading' => esc_html__( 'Button Skin', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Default', 'calla' ) => 'default',
|
||||
esc_html__( 'Light', 'calla' ) => 'light',
|
||||
esc_html__( 'Dark', 'calla' ) => 'dark'
|
||||
),
|
||||
'dependency' => array( 'element' => 'display_button', 'value' => array( 'yes' ) ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'colorpicker',
|
||||
'param_name' => 'shader_background_color',
|
||||
'heading' => esc_html__( 'Shader Background Color', 'calla' ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function render( $atts, $content = null ) {
|
||||
$default_atts = array(
|
||||
'type' => 'standard',
|
||||
'number_of_posts' => '8',
|
||||
'space_between_items' => 'normal',
|
||||
'orderby' => 'date',
|
||||
'order' => 'ASC',
|
||||
'taxonomy_to_display' => 'category',
|
||||
'taxonomy_values' => '',
|
||||
'image_size' => 'full',
|
||||
'number_of_visible_items' => '1',
|
||||
'slider_loop' => 'yes',
|
||||
'slider_autoplay' => 'yes',
|
||||
'slider_speed' => '5000',
|
||||
'slider_speed_animation' => '600',
|
||||
'slider_navigation' => 'yes',
|
||||
'slider_navigation_skin' => 'default',
|
||||
'slider_navigation_pos' => 'before-slider',
|
||||
'slider_pagination' => 'yes',
|
||||
'slider_pagination_skin' => 'default',
|
||||
'slider_pagination_pos' => 'bellow-slider',
|
||||
'display_title' => 'yes',
|
||||
'title_tag' => 'h6',
|
||||
'title_transform' => '',
|
||||
'display_category' => 'no',
|
||||
'display_rating' => 'yes',
|
||||
'display_price' => 'yes',
|
||||
'display_button' => 'yes',
|
||||
'button_skin' => 'default',
|
||||
'shader_background_color' => ''
|
||||
);
|
||||
$params = shortcode_atts( $default_atts, $atts );
|
||||
|
||||
$params['class_name'] = 'plc';
|
||||
$params['type'] = ! empty( $params['type'] ) ? $params['type'] : $default_atts['type'];
|
||||
$params['title_tag'] = ! empty( $params['title_tag'] ) ? $params['title_tag'] : $default_atts['title_tag'];
|
||||
|
||||
$additional_params = array();
|
||||
$additional_params['holder_classes'] = $this->getHolderClasses( $params, $default_atts );
|
||||
$additional_params['holder_data'] = $this->getProductListCarouselDataAttributes( $params );
|
||||
|
||||
$queryArray = $this->generateProductQueryArray( $params );
|
||||
$query_result = new \WP_Query( $queryArray );
|
||||
$additional_params['query_result'] = $query_result;
|
||||
|
||||
$params['this_object'] = $this;
|
||||
|
||||
$html = calla_elated_get_woo_shortcode_module_template_part( 'templates/product-list', 'product-list-carousel', $params['type'], $params, $additional_params );
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function getHolderClasses( $params, $default_atts ) {
|
||||
$holderClasses = array();
|
||||
$holderClasses[] = ! empty( $params['type'] ) ? 'eltdf-' . $params['type'] . '-layout' : 'eltdf-' . $default_atts['type'] . '-layout';
|
||||
$holderClasses[] = ! empty( $params['space_between_items'] ) ? 'eltdf-' . $params['space_between_items'] . '-space' : 'eltdf-' . $default_atts['space_between_items'] . '-space';
|
||||
$holderClasses[] = $this->getCarouselClasses( $params, $default_atts );
|
||||
|
||||
return implode( ' ', $holderClasses );
|
||||
}
|
||||
|
||||
private function getCarouselClasses( $params ) {
|
||||
$carouselClasses = array();
|
||||
$carouselClasses[] = ! empty( $params['slider_navigation_skin'] ) ? 'eltdf-plc-nav-' . $params['slider_navigation_skin'] . '-skin' : '';
|
||||
$carouselClasses[] = ! empty( $params['slider_navigation_pos'] ) ? 'eltdf-plc-nav-' . $params['slider_navigation_pos'] : '';
|
||||
$carouselClasses[] = ! empty( $params['slider_pagination_pos'] ) ? 'eltdf-plc-pag-' . $params['slider_pagination_pos'] : '';
|
||||
$carouselClasses[] = ! empty( $params['slider_pagination_skin'] ) ? 'eltdf-plc-pag-' . $params['slider_pagination_skin'] . '-skin' : '';
|
||||
|
||||
return implode( ' ', $carouselClasses );
|
||||
}
|
||||
|
||||
private function getProductListCarouselDataAttributes( $params ) {
|
||||
$slider_data = array();
|
||||
|
||||
$slider_data['data-number-of-items'] = ! empty( $params['number_of_visible_items'] ) && $params['type'] !== 'simple' ? $params['number_of_visible_items'] : '1';
|
||||
$slider_data['data-enable-loop'] = ! empty( $params['slider_loop'] ) ? $params['slider_loop'] : '';
|
||||
$slider_data['data-enable-autoplay'] = ! empty( $params['slider_autoplay'] ) ? $params['slider_autoplay'] : '';
|
||||
$slider_data['data-slider-speed'] = ! empty( $params['slider_speed'] ) ? $params['slider_speed'] : '5000';
|
||||
$slider_data['data-slider-speed-animation'] = ! empty( $params['slider_speed_animation'] ) ? $params['slider_speed_animation'] : '600';
|
||||
$slider_data['data-enable-navigation'] = ! empty( $params['slider_navigation'] ) ? $params['slider_navigation'] : '';
|
||||
$slider_data['data-enable-pagination'] = ! empty( $params['slider_pagination'] ) ? $params['slider_pagination'] : '';
|
||||
|
||||
return $slider_data;
|
||||
}
|
||||
|
||||
public function generateProductQueryArray( $params ) {
|
||||
$queryArray = array(
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'product',
|
||||
'ignore_sticky_posts' => 1,
|
||||
'posts_per_page' => $params['number_of_posts'],
|
||||
'orderby' => $params['orderby'],
|
||||
'order' => $params['order']
|
||||
);
|
||||
|
||||
if ( $params['orderby'] === 'on-sale' ) {
|
||||
$queryArray['no_found_rows'] = 1;
|
||||
$queryArray['post__in'] = array_merge( array( 0 ), wc_get_product_ids_on_sale() );
|
||||
}
|
||||
|
||||
if ( $params['taxonomy_to_display'] !== '' && $params['taxonomy_to_display'] === 'category' ) {
|
||||
$queryArray['product_cat'] = $params['taxonomy_values'];
|
||||
}
|
||||
|
||||
if ( $params['taxonomy_to_display'] !== '' && $params['taxonomy_to_display'] === 'tag' ) {
|
||||
$queryArray['product_tag'] = $params['taxonomy_values'];
|
||||
}
|
||||
|
||||
if ( $params['taxonomy_to_display'] !== '' && $params['taxonomy_to_display'] === 'id' ) {
|
||||
$idArray = $params['taxonomy_values'];
|
||||
$ids = explode( ',', $idArray );
|
||||
$queryArray['post__in'] = $ids;
|
||||
}
|
||||
|
||||
return $queryArray;
|
||||
}
|
||||
|
||||
public function getTitleStyles( $params ) {
|
||||
$styles = array();
|
||||
|
||||
if ( ! empty( $params['title_transform'] ) ) {
|
||||
$styles[] = 'text-transform: ' . $params['title_transform'];
|
||||
}
|
||||
|
||||
return implode( ';', $styles );
|
||||
}
|
||||
|
||||
public function getShaderStyles( $params ) {
|
||||
$styles = array();
|
||||
|
||||
if ( ! empty( $params['shader_background_color'] ) ) {
|
||||
$styles[] = 'background-color: ' . $params['shader_background_color'];
|
||||
}
|
||||
|
||||
return implode( ';', $styles );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
$shader_styles = $this_object->getShaderStyles( $params );
|
||||
$params['title_styles'] = $this_object->getTitleStyles( $params );
|
||||
?>
|
||||
<div class="eltdf-plc-holder <?php echo esc_attr( $holder_classes ) ?>">
|
||||
<div class="eltdf-plc-outer eltdf-owl-slider" <?php echo calla_elated_get_inline_attrs( $holder_data ); ?>>
|
||||
<?php if ( $query_result->have_posts() ): while ( $query_result->have_posts() ) : $query_result->the_post(); ?>
|
||||
<div class="eltdf-plc-item">
|
||||
<div class="eltdf-grid">
|
||||
<div class="eltdf-plc-image-outer">
|
||||
<div class="eltdf-plc-image">
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/image', 'woocommerce', '', $params ); ?>
|
||||
</div>
|
||||
<a class="eltdf-plc-link" itemprop="url" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"></a>
|
||||
</div>
|
||||
<div class="eltdf-plc-text-wrapper">
|
||||
<div class="eltdf-plc-text">
|
||||
<div class="eltdf-plc-text-outer">
|
||||
<div class="eltdf-plc-text-inner">
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/title', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/category', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/rating', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/price', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/add-to-cart', 'woocommerce', '', $params ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endwhile;
|
||||
else:
|
||||
calla_elated_get_module_template_part( 'templates/parts/no-posts', 'woocommerce', '', $params );
|
||||
endif;
|
||||
wp_reset_postdata();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
$shader_styles = $this_object->getShaderStyles( $params );
|
||||
$params['title_styles'] = $this_object->getTitleStyles( $params );
|
||||
?>
|
||||
<div class="eltdf-plc-holder <?php echo esc_attr( $holder_classes ) ?>">
|
||||
<div class="eltdf-plc-outer eltdf-owl-slider" <?php echo calla_elated_get_inline_attrs( $holder_data ); ?>>
|
||||
<?php if ( $query_result->have_posts() ): while ( $query_result->have_posts() ) : $query_result->the_post(); ?>
|
||||
<div class="eltdf-plc-item">
|
||||
<div class="eltdf-plc-image-outer">
|
||||
<div class="eltdf-plc-image">
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/image', 'woocommerce', '', $params ); ?>
|
||||
</div>
|
||||
<div class="eltdf-plc-text" <?php echo calla_elated_get_inline_style( $shader_styles ); ?>>
|
||||
<div class="eltdf-plc-text-outer">
|
||||
<div class="eltdf-plc-text-inner">
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/add-to-cart', 'woocommerce', '', $params ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a class="eltdf-plc-link" itemprop="url" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"></a>
|
||||
</div>
|
||||
<div class="eltdf-plc-text-wrapper">
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/title', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/category', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/rating', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/price', 'woocommerce', '', $params ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endwhile;
|
||||
else:
|
||||
calla_elated_get_module_template_part( 'templates/parts/no-posts', 'woocommerce', '', $params );
|
||||
endif;
|
||||
wp_reset_postdata();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'calla_elated_add_product_list_simple_shortcode' ) ) {
|
||||
function calla_elated_add_product_list_simple_shortcode( $shortcodes_class_name ) {
|
||||
$shortcodes = array(
|
||||
'CallaCore\CPT\Shortcodes\ProductListSimple\ProductListSimple',
|
||||
);
|
||||
|
||||
$shortcodes_class_name = array_merge( $shortcodes_class_name, $shortcodes );
|
||||
|
||||
return $shortcodes_class_name;
|
||||
}
|
||||
|
||||
if ( calla_elated_core_plugin_installed() ) {
|
||||
add_filter( 'calla_core_filter_add_vc_shortcode', 'calla_elated_add_product_list_simple_shortcode' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_add_product_list_simple_into_shortcodes_list' ) ) {
|
||||
function calla_elated_add_product_list_simple_into_shortcodes_list( $woocommerce_shortcodes ) {
|
||||
$woocommerce_shortcodes[] = 'eltdf_product_list_simple';
|
||||
|
||||
return $woocommerce_shortcodes;
|
||||
}
|
||||
|
||||
add_filter( 'calla_elated_woocommerce_shortcodes_list', 'calla_elated_add_product_list_simple_into_shortcodes_list' );
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/shortcodes/product-list-simple/functions.php';
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/shortcodes/product-list-simple/product-list-simple.php';
|
||||
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
|
||||
namespace CallaCore\CPT\Shortcodes\ProductListSimple;
|
||||
|
||||
use CallaCore\Lib;
|
||||
|
||||
class ProductListSimple implements Lib\ShortcodeInterface {
|
||||
private $base;
|
||||
|
||||
function __construct() {
|
||||
$this->base = 'eltdf_product_list_simple';
|
||||
|
||||
add_action( 'vc_before_init', array( $this, 'vcMap' ) );
|
||||
}
|
||||
|
||||
public function getBase() {
|
||||
return $this->base;
|
||||
}
|
||||
|
||||
public function vcMap() {
|
||||
if ( function_exists( 'vc_map' ) ) {
|
||||
vc_map(
|
||||
array(
|
||||
'name' => esc_html__( 'Elated Product List - Simple', 'calla' ),
|
||||
'base' => $this->base,
|
||||
'icon' => 'icon-wpb-product-list-simple extended-custom-icon',
|
||||
'category' => esc_html__( 'by ELATED', 'calla' ),
|
||||
'allowed_container_element' => 'vc_row',
|
||||
'params' => array(
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'type',
|
||||
'heading' => esc_html__( 'Type', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Sale', 'calla' ) => 'sale',
|
||||
esc_html__( 'Best Sellers', 'calla' ) => 'best-sellers',
|
||||
esc_html__( 'Featured', 'calla' ) => 'featured'
|
||||
),
|
||||
'save_always' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'param_name' => 'number',
|
||||
'heading' => esc_html__( 'Number of Products', 'calla' ),
|
||||
'description' => esc_html__( 'Number of products to show (default value is 4)', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'orderby',
|
||||
'heading' => esc_html__( 'Order By', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_query_order_by_array() ),
|
||||
'save_always' => true,
|
||||
'dependency' => array( 'element' => 'type', 'value' => array( 'sale', 'featured' ) )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'sort_order',
|
||||
'heading' => esc_html__( 'Order', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_query_order_array() ),
|
||||
'save_always' => true,
|
||||
'dependency' => array( 'element' => 'type', 'value' => array( 'sale', 'featured' ) )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'display_title',
|
||||
'heading' => esc_html__( 'Display Title', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'title_tag',
|
||||
'heading' => esc_html__( 'Title Tag', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_title_tag( true ) ),
|
||||
'save_always' => true,
|
||||
'dependency' => array( 'element' => 'display_title', 'value' => array( 'yes' ) )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'title_transform',
|
||||
'heading' => esc_html__( 'Title Text Transform', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_text_transform_array( true ) ),
|
||||
'save_always' => true,
|
||||
'dependency' => array( 'element' => 'display_title', 'value' => array( 'yes' ) )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'display_rating',
|
||||
'heading' => esc_html__( 'Display Rating', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'display_price',
|
||||
'heading' => esc_html__( 'Display Price', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) )
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function render( $atts, $content = null ) {
|
||||
$default_atts = array(
|
||||
'type' => 'sale',
|
||||
'number' => '4',
|
||||
'orderby' => 'title',
|
||||
'sort_order' => 'ASC',
|
||||
'display_title' => 'yes',
|
||||
'title_tag' => 'h5',
|
||||
'title_transform' => 'uppercase',
|
||||
'display_price' => 'yes',
|
||||
'display_rating' => 'yes'
|
||||
);
|
||||
$params = shortcode_atts( $default_atts, $atts );
|
||||
|
||||
$params['holder_classes'] = $this->getHolderClasses( $params );
|
||||
$params['class_name'] = 'pls';
|
||||
|
||||
$params['title_tag'] = ! empty( $params['title_tag'] ) ? $params['title_tag'] : $default_atts['title_tag'];
|
||||
$params['title_styles'] = $this->getTitleStyles( $params );
|
||||
|
||||
$queryArray = $this->generateProductQueryArray( $params );
|
||||
$query_result = new \WP_Query( $queryArray );
|
||||
$params['query_result'] = $query_result;
|
||||
|
||||
$html = calla_elated_get_woo_shortcode_module_template_part( 'templates/product-list-template', 'product-list-simple', '', $params );
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function getHolderClasses( $params ) {
|
||||
$holderClasses = '';
|
||||
$productListType = $params['type'];
|
||||
|
||||
switch ( $productListType ) {
|
||||
case 'sale':
|
||||
$holderClasses = 'eltdf-pls-sale';
|
||||
break;
|
||||
case 'best-sellers':
|
||||
$holderClasses = 'eltdf-pls-best-sellers';
|
||||
break;
|
||||
case 'featured':
|
||||
$holderClasses = 'eltdf-pls-featured';
|
||||
break;
|
||||
default:
|
||||
$holderClasses = 'eltdf-pls-sale';
|
||||
break;
|
||||
}
|
||||
|
||||
return $holderClasses;
|
||||
}
|
||||
|
||||
private function generateProductQueryArray( $params ) {
|
||||
switch ( $params['type'] ) {
|
||||
case 'sale':
|
||||
$args = array(
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'product',
|
||||
'posts_per_page' => $params['number'],
|
||||
'orderby' => $params['orderby'],
|
||||
'order' => $params['sort_order'],
|
||||
'no_found_rows' => 1,
|
||||
'post__in' => array_merge( array( 0 ), wc_get_product_ids_on_sale() )
|
||||
);
|
||||
break;
|
||||
case 'best-sellers':
|
||||
$args = array(
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'product',
|
||||
'ignore_sticky_posts' => 1,
|
||||
'posts_per_page' => $params['number'],
|
||||
'meta_key' => 'total_sales',
|
||||
'orderby' => 'meta_value_num'
|
||||
);
|
||||
break;
|
||||
case 'featured':
|
||||
$args = array(
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'product',
|
||||
'posts_per_page' => $params['number'],
|
||||
'orderby' => $params['orderby'],
|
||||
'order' => $params['sort_order'],
|
||||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'product_visibility',
|
||||
'field' => 'name',
|
||||
'terms' => 'featured',
|
||||
),
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
private function getTitleStyles( $params ) {
|
||||
$styles = array();
|
||||
|
||||
if ( ! empty( $params['title_transform'] ) ) {
|
||||
$styles[] = 'text-transform: ' . $params['title_transform'];
|
||||
}
|
||||
|
||||
return implode( ';', $styles );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<div class="eltdf-pls-holder <?php echo esc_attr($holder_classes) ?>">
|
||||
<ul class="eltdf-pls-inner">
|
||||
<?php if($query_result->have_posts()): while ($query_result->have_posts()) : $query_result->the_post(); ?>
|
||||
<li class="eltdf-pls-item">
|
||||
<div class="eltdf-pls-image">
|
||||
<a itemprop="url" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
|
||||
<?php calla_elated_get_module_template_part('templates/parts/image-simple', 'woocommerce', '', $params); ?>
|
||||
</a>
|
||||
</div>
|
||||
<div class="eltdf-pls-text">
|
||||
<?php calla_elated_get_module_template_part('templates/parts/title', 'woocommerce', '', $params); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part('templates/parts/rating', 'woocommerce', '', $params); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part('templates/parts/price', 'woocommerce', '', $params); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php endwhile; else: ?>
|
||||
<li class="eltdf-pls-messsage">
|
||||
<?php calla_elated_get_module_template_part('templates/parts/no-posts', 'woocommerce', '', $params); ?>
|
||||
</li>
|
||||
<?php endif;
|
||||
wp_reset_postdata();
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'calla_elated_add_product_list_shortcode' ) ) {
|
||||
function calla_elated_add_product_list_shortcode( $shortcodes_class_name ) {
|
||||
$shortcodes = array(
|
||||
'CallaCore\CPT\Shortcodes\ProductList\ProductList',
|
||||
);
|
||||
|
||||
$shortcodes_class_name = array_merge( $shortcodes_class_name, $shortcodes );
|
||||
|
||||
return $shortcodes_class_name;
|
||||
}
|
||||
|
||||
if ( calla_elated_core_plugin_installed() ) {
|
||||
add_filter( 'calla_core_filter_add_vc_shortcode', 'calla_elated_add_product_list_shortcode' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_add_product_list_into_shortcodes_list' ) ) {
|
||||
function calla_elated_add_product_list_into_shortcodes_list( $woocommerce_shortcodes ) {
|
||||
$woocommerce_shortcodes[] = 'eltdf_product_list';
|
||||
|
||||
return $woocommerce_shortcodes;
|
||||
}
|
||||
|
||||
add_filter( 'calla_elated_woocommerce_shortcodes_list', 'calla_elated_add_product_list_into_shortcodes_list' );
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/shortcodes/product-list/functions.php';
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/shortcodes/product-list/product-list.php';
|
||||
@@ -0,0 +1,415 @@
|
||||
<?php
|
||||
|
||||
namespace CallaCore\CPT\Shortcodes\ProductList;
|
||||
|
||||
use CallaCore\Lib;
|
||||
|
||||
class ProductList implements Lib\ShortcodeInterface {
|
||||
private $base;
|
||||
|
||||
function __construct() {
|
||||
$this->base = 'eltdf_product_list';
|
||||
|
||||
add_action( 'vc_before_init', array( $this, 'vcMap' ) );
|
||||
}
|
||||
|
||||
public function getBase() {
|
||||
return $this->base;
|
||||
}
|
||||
|
||||
public function vcMap() {
|
||||
if ( function_exists( 'vc_map' ) ) {
|
||||
vc_map(
|
||||
array(
|
||||
'name' => esc_html__( 'Elated Product List', 'calla' ),
|
||||
'base' => $this->base,
|
||||
'icon' => 'icon-wpb-product-list extended-custom-icon',
|
||||
'category' => esc_html__( 'by ELATED', 'calla' ),
|
||||
'allowed_container_element' => 'vc_row',
|
||||
'params' => array(
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'type',
|
||||
'heading' => esc_html__( 'Type', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Standard', 'calla' ) => 'standard',
|
||||
esc_html__( 'Masonry', 'calla' ) => 'masonry'
|
||||
),
|
||||
'admin_label' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'info_position',
|
||||
'heading' => esc_html__( 'Product Info Position', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Info On Image Hover', 'calla' ) => 'info-on-image',
|
||||
esc_html__( 'Info Below Image', 'calla' ) => 'info-below-image'
|
||||
),
|
||||
'save_always' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'param_name' => 'number_of_posts',
|
||||
'heading' => esc_html__( 'Number of Products', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'number_of_columns',
|
||||
'heading' => esc_html__( 'Number of Columns', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'One', 'calla' ) => '1',
|
||||
esc_html__( 'Two', 'calla' ) => '2',
|
||||
esc_html__( 'Three', 'calla' ) => '3',
|
||||
esc_html__( 'Four', 'calla' ) => '4',
|
||||
esc_html__( 'Five', 'calla' ) => '5',
|
||||
esc_html__( 'Six', 'calla' ) => '6'
|
||||
),
|
||||
'save_always' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'space_between_items',
|
||||
'heading' => esc_html__( 'Space Between Items', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_space_between_items_array() ),
|
||||
'save_always' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'orderby',
|
||||
'heading' => esc_html__( 'Order By', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_query_order_by_array( false, array( 'on-sale' => esc_html__( 'On Sale', 'calla' ) ) ) ),
|
||||
'save_always' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'order',
|
||||
'heading' => esc_html__( 'Order', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_query_order_array() ),
|
||||
'save_always' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'taxonomy_to_display',
|
||||
'heading' => esc_html__( 'Choose Sorting Taxonomy', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Category', 'calla' ) => 'category',
|
||||
esc_html__( 'Tag', 'calla' ) => 'tag',
|
||||
esc_html__( 'Id', 'calla' ) => 'id'
|
||||
),
|
||||
'save_always' => true,
|
||||
'description' => esc_html__( 'If you would like to display only certain products, this is where you can select the criteria by which you would like to choose which products to display', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'param_name' => 'taxonomy_values',
|
||||
'heading' => esc_html__( 'Enter Taxonomy Values', 'calla' ),
|
||||
'description' => esc_html__( 'Separate values (category slugs, tags, or post IDs) with a comma', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'image_size',
|
||||
'heading' => esc_html__( 'Image Proportions', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Default', 'calla' ) => '',
|
||||
esc_html__( 'Original', 'calla' ) => 'full',
|
||||
esc_html__( 'Square', 'calla' ) => 'square',
|
||||
esc_html__( 'Landscape', 'calla' ) => 'landscape',
|
||||
esc_html__( 'Portrait', 'calla' ) => 'portrait',
|
||||
esc_html__( 'Medium', 'calla' ) => 'medium',
|
||||
esc_html__( 'Large', 'calla' ) => 'large',
|
||||
esc_html__( 'Shop Single', 'calla' ) => 'woocommerce_single',
|
||||
esc_html__( 'Shop Thumbnail', 'calla' ) => 'woocommerce_thumbnail'
|
||||
),
|
||||
'save_always' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'display_title',
|
||||
'heading' => esc_html__( 'Display Title', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) ),
|
||||
'group' => esc_html__( 'Product Info', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'product_info_skin',
|
||||
'heading' => esc_html__( 'Product Info Skin', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Default', 'calla' ) => 'default',
|
||||
esc_html__( 'Light', 'calla' ) => 'light',
|
||||
esc_html__( 'Dark', 'calla' ) => 'dark'
|
||||
),
|
||||
'dependency' => array( 'element' => 'info_position', 'value' => array( 'info-on-image' ) ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'title_tag',
|
||||
'heading' => esc_html__( 'Title Tag', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_title_tag( true ) ),
|
||||
'dependency' => array( 'element' => 'display_title', 'value' => array( 'yes' ) ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'title_transform',
|
||||
'heading' => esc_html__( 'Title Text Transform', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_text_transform_array( true ) ),
|
||||
'dependency' => array( 'element' => 'display_title', 'value' => array( 'yes' ) ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'display_category',
|
||||
'heading' => esc_html__( 'Display Category', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false ) ),
|
||||
'group' => esc_html__( 'Product Info', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'display_rating',
|
||||
'heading' => esc_html__( 'Display Rating', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) ),
|
||||
'group' => esc_html__( 'Product Info', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'display_price',
|
||||
'heading' => esc_html__( 'Display Price', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) ),
|
||||
'group' => esc_html__( 'Product Info', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'display_button',
|
||||
'heading' => esc_html__( 'Display Button', 'calla' ),
|
||||
'value' => array_flip( calla_elated_get_yes_no_select_array( false, true ) ),
|
||||
'group' => esc_html__( 'Product Info', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'button_skin',
|
||||
'heading' => esc_html__( 'Button Skin', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Default', 'calla' ) => 'default',
|
||||
esc_html__( 'Light', 'calla' ) => 'light',
|
||||
esc_html__( 'Dark', 'calla' ) => 'dark'
|
||||
),
|
||||
'dependency' => array( 'element' => 'display_button', 'value' => array( 'yes' ) ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'colorpicker',
|
||||
'param_name' => 'shader_background_color',
|
||||
'heading' => esc_html__( 'Shader Background Color', 'calla' ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'param_name' => 'info_bottom_text_align',
|
||||
'heading' => esc_html__( 'Product Info Text Alignment', 'calla' ),
|
||||
'value' => array(
|
||||
esc_html__( 'Default', 'calla' ) => '',
|
||||
esc_html__( 'Left', 'calla' ) => 'left',
|
||||
esc_html__( 'Center', 'calla' ) => 'center',
|
||||
esc_html__( 'Right', 'calla' ) => 'right'
|
||||
),
|
||||
'dependency' => array( 'element' => 'info_position', 'value' => array( 'info-below-image' ) ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'param_name' => 'info_bottom_margin',
|
||||
'heading' => esc_html__( 'Product Info Bottom Margin (px)', 'calla' ),
|
||||
'dependency' => array( 'element' => 'info_position', 'value' => array( 'info-below-image' ) ),
|
||||
'group' => esc_html__( 'Product Info Style', 'calla' )
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function render( $atts, $content = null ) {
|
||||
$default_atts = array(
|
||||
'type' => 'standard',
|
||||
'info_position' => 'info-on-image',
|
||||
'number_of_posts' => '8',
|
||||
'number_of_columns' => '4',
|
||||
'space_between_items' => 'normal',
|
||||
'orderby' => 'date',
|
||||
'order' => 'ASC',
|
||||
'taxonomy_to_display' => 'category',
|
||||
'taxonomy_values' => '',
|
||||
'image_size' => 'full',
|
||||
'display_title' => 'yes',
|
||||
'product_info_skin' => '',
|
||||
'title_tag' => 'h6',
|
||||
'title_transform' => '',
|
||||
'display_category' => 'no',
|
||||
'display_rating' => 'yes',
|
||||
'display_price' => 'yes',
|
||||
'display_button' => 'yes',
|
||||
'button_skin' => 'default',
|
||||
'shader_background_color' => '',
|
||||
'info_bottom_text_align' => '',
|
||||
'info_bottom_margin' => ''
|
||||
);
|
||||
$params = shortcode_atts( $default_atts, $atts );
|
||||
|
||||
$params['class_name'] = 'pli';
|
||||
$params['type'] = ! empty( $params['type'] ) ? $params['type'] : $default_atts['type'];
|
||||
$params['info_position'] = ! empty( $params['info_position'] ) ? $params['info_position'] : $default_atts['info_position'];
|
||||
$params['title_tag'] = ! empty( $params['title_tag'] ) ? $params['title_tag'] : $default_atts['title_tag'];
|
||||
$params['layout_classes'] = $this->getLayoutClasses( $params );
|
||||
|
||||
$additional_params = array();
|
||||
$additional_params['holder_classes'] = $this->getHolderClasses( $params, $default_atts );
|
||||
|
||||
$queryArray = $this->generateProductQueryArray( $params );
|
||||
$query_result = new \WP_Query( $queryArray );
|
||||
$additional_params['query_result'] = $query_result;
|
||||
|
||||
$params['this_object'] = $this;
|
||||
|
||||
$html = calla_elated_get_woo_shortcode_module_template_part( 'templates/product-list', 'product-list', $params['type'], $params, $additional_params );
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function getHolderClasses( $params, $default_atts ) {
|
||||
$holderClasses = array();
|
||||
$holderClasses[] = ! empty( $params['type'] ) ? 'eltdf-' . $params['type'] . '-layout' : 'eltdf-' . $default_atts['type'] . '-layout';
|
||||
$holderClasses[] = ! empty( $params['space_between_items'] ) ? 'eltdf-' . $params['space_between_items'] . '-space' : 'eltdf-' . $default_atts['space_between_items'] . '-space';
|
||||
$holderClasses[] = $this->getColumnNumberClass( $params );
|
||||
$holderClasses[] = ! empty( $params['info_position'] ) ? 'eltdf-' . $params['info_position'] : 'eltdf-' . $default_atts['info_position'];
|
||||
$holderClasses[] = ! empty( $params['product_info_skin'] ) ? 'eltdf-product-info-' . $params['product_info_skin'] : '';
|
||||
|
||||
return implode( ' ', $holderClasses );
|
||||
}
|
||||
|
||||
private function getLayoutClasses( $params ) {
|
||||
$layoutClasses = array();
|
||||
//change to true if hover is changed to from bottom
|
||||
$btn_from_bottom = false;
|
||||
$btn_position_class = '';
|
||||
|
||||
if ( $params['info_position'] == 'info-below-image' && $btn_from_bottom) {
|
||||
$btn_position_class = 'eltdf-pli-button-from-bottom';
|
||||
} else {
|
||||
$btn_position_class = 'eltdf-pli-hover-overlay';
|
||||
}
|
||||
|
||||
$layoutClasses[] = $btn_position_class;
|
||||
|
||||
return implode( ' ', $layoutClasses );
|
||||
}
|
||||
|
||||
private function getColumnNumberClass( $params ) {
|
||||
$columnsNumber = '';
|
||||
$columns = $params['number_of_columns'];
|
||||
|
||||
switch ( $columns ) {
|
||||
case 1:
|
||||
$columnsNumber = 'eltdf-one-column';
|
||||
break;
|
||||
case 2:
|
||||
$columnsNumber = 'eltdf-two-columns';
|
||||
break;
|
||||
case 3:
|
||||
$columnsNumber = 'eltdf-three-columns';
|
||||
break;
|
||||
case 4:
|
||||
$columnsNumber = 'eltdf-four-columns';
|
||||
break;
|
||||
case 5:
|
||||
$columnsNumber = 'eltdf-five-columns';
|
||||
break;
|
||||
case 6:
|
||||
$columnsNumber = 'eltdf-six-columns';
|
||||
break;
|
||||
default:
|
||||
$columnsNumber = 'eltdf-four-columns';
|
||||
break;
|
||||
}
|
||||
|
||||
return $columnsNumber;
|
||||
}
|
||||
|
||||
private function generateProductQueryArray( $params ) {
|
||||
$queryArray = array(
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'product',
|
||||
'ignore_sticky_posts' => 1,
|
||||
'posts_per_page' => $params['number_of_posts'],
|
||||
'orderby' => $params['orderby'],
|
||||
'order' => $params['order']
|
||||
);
|
||||
|
||||
if ( $params['orderby'] === 'on-sale' ) {
|
||||
$queryArray['no_found_rows'] = 1;
|
||||
$queryArray['post__in'] = array_merge( array( 0 ), wc_get_product_ids_on_sale() );
|
||||
}
|
||||
|
||||
if ( $params['taxonomy_to_display'] !== '' && $params['taxonomy_to_display'] === 'category' ) {
|
||||
$queryArray['product_cat'] = $params['taxonomy_values'];
|
||||
}
|
||||
|
||||
if ( $params['taxonomy_to_display'] !== '' && $params['taxonomy_to_display'] === 'tag' ) {
|
||||
$queryArray['product_tag'] = $params['taxonomy_values'];
|
||||
}
|
||||
|
||||
if ( $params['taxonomy_to_display'] !== '' && $params['taxonomy_to_display'] === 'id' ) {
|
||||
$idArray = $params['taxonomy_values'];
|
||||
$ids = explode( ',', $idArray );
|
||||
$queryArray['post__in'] = $ids;
|
||||
}
|
||||
|
||||
return $queryArray;
|
||||
}
|
||||
|
||||
public function getItemClasses( $params ) {
|
||||
$itemClasses = array();
|
||||
|
||||
$image_size_meta = get_post_meta( get_the_ID(), 'eltdf_product_featured_image_size', true );
|
||||
|
||||
if ( ! empty( $image_size_meta ) ) {
|
||||
$itemClasses[] = $image_size_meta;
|
||||
}
|
||||
|
||||
return implode( ' ', $itemClasses );
|
||||
}
|
||||
|
||||
public function getTitleStyles( $params ) {
|
||||
$styles = array();
|
||||
|
||||
if ( ! empty( $params['title_transform'] ) ) {
|
||||
$styles[] = 'text-transform: ' . $params['title_transform'];
|
||||
}
|
||||
|
||||
return implode( ';', $styles );
|
||||
}
|
||||
|
||||
public function getShaderStyles( $params ) {
|
||||
$styles = array();
|
||||
|
||||
if ( ! empty( $params['shader_background_color'] ) ) {
|
||||
$styles[] = 'background-color: ' . $params['shader_background_color'];
|
||||
}
|
||||
|
||||
return implode( ';', $styles );
|
||||
}
|
||||
|
||||
public function getTextWrapperStyles( $params ) {
|
||||
$styles = array();
|
||||
|
||||
if ( ! empty( $params['info_bottom_text_align'] ) ) {
|
||||
$styles[] = 'text-align: ' . $params['info_bottom_text_align'];
|
||||
}
|
||||
|
||||
if ( $params['info_bottom_margin'] !== '' ) {
|
||||
$styles[] = 'margin-bottom: ' . calla_elated_filter_px( $params['info_bottom_margin'] ) . 'px';
|
||||
}
|
||||
|
||||
return implode( ';', $styles );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
$item_classes = $this_object->getItemClasses( $params );
|
||||
$shader_styles = $this_object->getShaderStyles( $params );
|
||||
$text_wrapper_styles = $this_object->getTextWrapperStyles( $params );
|
||||
$params['title_styles'] = $this_object->getTitleStyles( $params );
|
||||
?>
|
||||
<div class="eltdf-pli eltdf-item-space <?php echo esc_attr( $item_classes ); ?>">
|
||||
<div class="eltdf-pli-inner">
|
||||
<div class="eltdf-pli-image">
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/image', 'woocommerce', '', $params ); ?>
|
||||
</div>
|
||||
<div class="eltdf-pli-text <?php echo esc_attr($layout_classes);?>" <?php echo calla_elated_get_inline_style( $shader_styles ); ?>>
|
||||
<div class="eltdf-pli-text-outer">
|
||||
<div class="eltdf-pli-text-inner">
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/add-to-cart', 'woocommerce', '', $params ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a class="eltdf-pli-link" itemprop="url" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"></a>
|
||||
</div>
|
||||
<div class="eltdf-pli-text-wrapper" <?php echo calla_elated_get_inline_style( $text_wrapper_styles ); ?>>
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/title', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/category', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/rating', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/price', 'woocommerce', '', $params ); ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
$item_classes = $this_object->getItemClasses( $params );
|
||||
$shader_styles = $this_object->getShaderStyles( $params );
|
||||
$params['title_styles'] = $this_object->getTitleStyles( $params );
|
||||
?>
|
||||
<div class="eltdf-pli eltdf-item-space <?php echo esc_attr( $item_classes ); ?>">
|
||||
<div class="eltdf-pli-inner">
|
||||
<div class="eltdf-pli-image">
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/image', 'woocommerce', '', $params ); ?>
|
||||
</div>
|
||||
<div class="eltdf-pli-text <?php echo esc_attr($layout_classes);?>" <?php echo calla_elated_get_inline_style( $shader_styles ); ?>>
|
||||
<div class="eltdf-pli-text-outer">
|
||||
<div class="eltdf-pli-text-inner">
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/title', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/category', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/rating', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/price', 'woocommerce', '', $params ); ?>
|
||||
|
||||
<?php calla_elated_get_module_template_part( 'templates/parts/add-to-cart', 'woocommerce', '', $params ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a class="eltdf-pli-link" itemprop="url" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"></a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,14 @@
|
||||
<div class="eltdf-pl-holder <?php echo esc_attr( $holder_classes ) ?>">
|
||||
<div class="eltdf-pl-outer eltdf-outer-space">
|
||||
<div class="eltdf-pl-sizer"></div>
|
||||
<div class="eltdf-pl-gutter"></div>
|
||||
<?php if ( $query_result->have_posts() ): while ( $query_result->have_posts() ) : $query_result->the_post();
|
||||
echo calla_elated_get_woo_shortcode_module_template_part( 'templates/parts/' . $info_position, 'product-list', '', $params );
|
||||
endwhile;
|
||||
else:
|
||||
calla_elated_get_module_template_part( 'templates/parts/no-posts', 'woocommerce', '', $params );
|
||||
endif;
|
||||
wp_reset_postdata();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
<div class="eltdf-pl-holder <?php echo esc_attr( $holder_classes ) ?>">
|
||||
<div class="eltdf-pl-outer eltdf-outer-space">
|
||||
<?php if ( $query_result->have_posts() ): while ( $query_result->have_posts() ) : $query_result->the_post();
|
||||
echo calla_elated_get_woo_shortcode_module_template_part( 'templates/parts/' . $info_position, 'product-list', '', $params );
|
||||
endwhile;
|
||||
else:
|
||||
calla_elated_get_module_template_part( 'templates/parts/no-posts', 'woocommerce', '', $params );
|
||||
endif;
|
||||
wp_reset_postdata();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'calla_elated_include_woocommerce_shortcodes' ) ) {
|
||||
function calla_elated_include_woocommerce_shortcodes() {
|
||||
foreach ( glob( ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/shortcodes/*/load.php' ) as $shortcode_load ) {
|
||||
include_once $shortcode_load;
|
||||
}
|
||||
}
|
||||
|
||||
if ( calla_elated_core_plugin_installed() ) {
|
||||
add_action( 'calla_core_action_include_shortcodes_file', 'calla_elated_include_woocommerce_shortcodes' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_set_product_list_icon_class_name_for_vc_shortcodes' ) ) {
|
||||
/**
|
||||
* Function that set custom icon class name for product shortcodes to set our icon for Visual Composer shortcodes panel
|
||||
*/
|
||||
function calla_elated_set_product_list_icon_class_name_for_vc_shortcodes( $shortcodes_icon_class_array ) {
|
||||
$shortcodes_icon_class_array[] = '.icon-wpb-product-info';
|
||||
$shortcodes_icon_class_array[] = '.icon-wpb-product-list';
|
||||
$shortcodes_icon_class_array[] = '.icon-wpb-product-list-carousel';
|
||||
$shortcodes_icon_class_array[] = '.icon-wpb-product-list-simple';
|
||||
|
||||
return $shortcodes_icon_class_array;
|
||||
}
|
||||
|
||||
if ( calla_elated_core_plugin_installed() ) {
|
||||
add_filter( 'calla_core_filter_add_vc_shortcodes_custom_icon_class', 'calla_elated_set_product_list_icon_class_name_for_vc_shortcodes' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
if($display_button === 'yes') {
|
||||
$product = calla_elated_return_woocommerce_global_variable();
|
||||
|
||||
$buttonSkinClass = '';
|
||||
if(!empty($button_skin)) {
|
||||
$buttonSkinClass = 'eltdf-'.$button_skin.'-skin';
|
||||
}
|
||||
|
||||
if (!$product->is_in_stock()) {
|
||||
$button_classes = 'button ajax_add_to_cart eltdf-btn eltdf-btn-outline eltdf-btn-double-border eltdf-btn-small';
|
||||
} else if ($product->get_type() === 'variable') {
|
||||
$button_classes = 'button product_type_variable add_to_cart_button eltdf-btn eltdf-btn-outline eltdf-btn-double-border eltdf-btn-small';
|
||||
} else if ($product->get_type() === 'external') {
|
||||
$button_classes = 'button product_type_external eltdf-btn eltdf-btn-outline eltdf-btn-double-border eltdf-btn-small';
|
||||
} else {
|
||||
$button_classes = 'button add_to_cart_button ajax_add_to_cart eltdf-btn eltdf-btn-outline eltdf-btn-double-border eltdf-btn-small';
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="eltdf-<?php echo esc_attr($class_name); ?>-add-to-cart <?php echo esc_attr($buttonSkinClass); ?>">
|
||||
<?php echo apply_filters( 'calla_elated_product_list_add_to_cart_link',
|
||||
sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s"> <span class="eltdf-btn-border eltdf-btn-border-first"></span>
|
||||
<span class="eltdf-btn-border eltdf-btn-border-second"></span>%s</a>',
|
||||
esc_url( $product->add_to_cart_url() ),
|
||||
esc_attr( isset( $quantity ) ? $quantity : 1 ),
|
||||
esc_attr( $product->get_id() ),
|
||||
esc_attr( $product->get_sku() ),
|
||||
esc_attr( $button_classes ),
|
||||
esc_html( $product->add_to_cart_text() )
|
||||
),
|
||||
$product ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
if($display_category === 'yes') {
|
||||
$product = calla_elated_return_woocommerce_global_variable();
|
||||
$product_categories = wc_get_product_category_list( $product->get_id(), ', ' );
|
||||
|
||||
if (!empty($product_categories)) { ?>
|
||||
<p class="eltdf-<?php echo esc_attr($class_name); ?>-category"><?php echo wp_kses_post($product_categories); ?></p>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
if($display_excerpt === 'yes' && $excerpt_length > 0) {
|
||||
$excerpt = ($excerpt_length > 0) ? substr(get_the_excerpt(), 0, intval($excerpt_length)) : get_the_excerpt();
|
||||
?>
|
||||
|
||||
<p itemprop="description" class="eltdf-<?php echo esc_attr($class_name); ?>-excerpt"><?php echo esc_html($excerpt); ?></p>
|
||||
<?php } ?>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$product_image_size = 'woocommerce_thumbnail';
|
||||
|
||||
if(has_post_thumbnail()) {
|
||||
the_post_thumbnail(apply_filters( 'calla_elated_product_list_image_simple_size', $product_image_size));
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
$product = calla_elated_return_woocommerce_global_variable();
|
||||
|
||||
if ( $product->is_on_sale() ) { ?>
|
||||
<span class="eltdf-<?php echo esc_attr( $class_name ); ?>-onsale"><?php esc_html_e( 'Sale', 'calla' ); ?></span>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( ! $product->is_in_stock() ) { ?>
|
||||
<span class="eltdf-<?php echo esc_attr( $class_name ); ?>-out-of-stock"><?php esc_html_e( 'wyprzedane', 'calla' ); ?></span>
|
||||
<?php }
|
||||
|
||||
$new = get_post_meta( get_the_ID(), 'eltdf_show_new_sign_woo_meta', true );
|
||||
|
||||
if ( $new === 'yes' ) { ?>
|
||||
<span class="eltdf-<?php echo esc_attr( $class_name ); ?>-new-product"><?php esc_html_e( 'New', 'calla' ); ?></span>
|
||||
<?php }
|
||||
|
||||
$product_image_size = 'woocommerce_single';
|
||||
if ( $image_size === 'full' ) {
|
||||
$product_image_size = 'full';
|
||||
} else if ( $image_size === 'square' ) {
|
||||
$product_image_size = 'calla_elated_square';
|
||||
} else if ( $image_size === 'landscape' ) {
|
||||
$product_image_size = 'calla_elated_landscape';
|
||||
} else if ( $image_size === 'portrait' ) {
|
||||
$product_image_size = 'calla_elated_portrait';
|
||||
} else if ( $image_size === 'medium' ) {
|
||||
$product_image_size = 'medium';
|
||||
} else if ( $image_size === 'large' ) {
|
||||
$product_image_size = 'large';
|
||||
} else if ( $image_size === 'woocommerce_thumbnail' ) {
|
||||
$product_image_size = 'woocommerce_thumbnail';
|
||||
}
|
||||
|
||||
if ( has_post_thumbnail() ) {
|
||||
the_post_thumbnail( apply_filters( 'calla_elated_product_list_image_size', $product_image_size ) );
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<div class="eltdf-<?php echo esc_attr($class_name); ?>-messsage"><p><?php esc_html_e('No products were found!', 'calla'); ?></p></div>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$product = calla_elated_return_woocommerce_global_variable();
|
||||
|
||||
if ($display_price === 'yes' && $price_html = $product->get_price_html()) { ?>
|
||||
<div class="eltdf-<?php echo esc_attr($class_name); ?>-price"><?php echo wp_kses_post($price_html); ?></div>
|
||||
<?php } ?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
if ($display_rating === 'yes' && get_option( 'woocommerce_enable_review_rating' ) !== 'no') {
|
||||
$product = calla_elated_return_woocommerce_global_variable();
|
||||
$average = $product->get_average_rating();
|
||||
?>
|
||||
<?php if ($average > 0){?>
|
||||
<div class="eltdf-<?php echo esc_attr($class_name); ?>-rating-holder">
|
||||
<div class="eltdf-<?php echo esc_attr($class_name); ?>-rating" title="<?php sprintf(esc_attr_e("Rated %s out of 5", "calla"), $average ); ?>">
|
||||
<span style="width: <?php echo esc_attr( ( $average / 5 ) * 100 ) . '%'; ?>"></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php }?>
|
||||
<?php } ?>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
if($display_title === 'yes') { ?>
|
||||
<<?php echo esc_attr($title_tag); ?> itemprop="name" class="entry-title eltdf-<?php echo esc_attr($class_name); ?>-title" <?php echo calla_elated_get_inline_style($title_styles); ?>>
|
||||
<a itemprop="url" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
|
||||
</<?php echo esc_attr($title_tag); ?>>
|
||||
<?php } ?>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'calla_elated_dropdown_cart_icon_styles' ) ) {
|
||||
/**
|
||||
* Generates styles for dropdown cart icon
|
||||
*/
|
||||
function calla_elated_dropdown_cart_icon_styles() {
|
||||
$icon_color = calla_elated_options()->getOptionValue( 'dropdown_cart_icon_color' );
|
||||
$icon_hover_color = calla_elated_options()->getOptionValue( 'dropdown_cart_hover_color' );
|
||||
|
||||
if ( ! empty( $icon_color ) ) {
|
||||
echo calla_elated_dynamic_css( '.eltdf-shopping-cart-holder .eltdf-header-cart a', array( 'color' => $icon_color ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $icon_hover_color ) ) {
|
||||
echo calla_elated_dynamic_css( '.eltdf-shopping-cart-holder .eltdf-header-cart a:hover', array( 'color' => $icon_hover_color ) );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'calla_elated_style_dynamic', 'calla_elated_dropdown_cart_icon_styles' );
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_dropdown_cart_options_map' ) ) {
|
||||
|
||||
/**
|
||||
* Add Woocommerce dropdown cart options to WooCommerce options page
|
||||
*/
|
||||
function calla_elated_woocommerce_dropdown_cart_options_map() {
|
||||
|
||||
/**
|
||||
* WooCommerce Dropdown Cart Settings
|
||||
*/
|
||||
$panel_dropdown_cart = calla_elated_add_admin_panel(
|
||||
array(
|
||||
'page' => '_woocommerce_page',
|
||||
'name' => 'panel_dropdown_cart',
|
||||
'title' => esc_html__( 'Dropdown Cart', 'calla' )
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'parent' => $panel_dropdown_cart,
|
||||
'type' => 'select',
|
||||
'name' => 'dropdown_cart_icon_source',
|
||||
'default_value' => 'icon_pack',
|
||||
'label' => esc_html__( 'Select Drodown Cart Icon Source', 'calla' ),
|
||||
'description' => esc_html__( 'Choose whether you would like to use icons from an icon pack or SVG icons', 'calla' ),
|
||||
'options' => calla_elated_get_icon_sources_array()
|
||||
)
|
||||
);
|
||||
|
||||
$dropdwon_cart_icon_pack_container = calla_elated_add_admin_container(
|
||||
array(
|
||||
'parent' => $panel_dropdown_cart,
|
||||
'name' => 'dropdwon_cart_icon_pack_container',
|
||||
'dependency' => array(
|
||||
'show' => array(
|
||||
'dropdown_cart_icon_source' => 'icon_pack'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'parent' => $dropdwon_cart_icon_pack_container,
|
||||
'type' => 'select',
|
||||
'name' => 'dropdown_cart_icon_pack',
|
||||
'default_value' => 'font_elegant',
|
||||
'label' => esc_html__( 'Dropdown Cart Icon Pack', 'calla' ),
|
||||
'description' => esc_html__( 'Choose icon pack for dropdown cart icon', 'calla' ),
|
||||
'options' => calla_elated_icon_collections()->getIconCollectionsExclude( array( 'linea_icons', 'dripicons', 'simple_line_icons' ) )
|
||||
)
|
||||
);
|
||||
|
||||
$dropdwon_cart_icon_svg_path_container = calla_elated_add_admin_container(
|
||||
array(
|
||||
'parent' => $panel_dropdown_cart,
|
||||
'name' => 'dropdwon_cart_icon_svg_path_container',
|
||||
'dependency' => array(
|
||||
'show' => array(
|
||||
'dropdown_cart_icon_source' => 'svg_path'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'parent' => $dropdwon_cart_icon_svg_path_container,
|
||||
'type' => 'textarea',
|
||||
'name' => 'dropdown_cart_icon_svg_path',
|
||||
'label' => esc_html__( 'Dropdown Cart Icon SVG Path', 'calla' ),
|
||||
'description' => esc_html__( 'Enter your dropdown cart icon SVG path here. Please remove version and id attributes from your SVG path because of HTML validation', 'calla' ),
|
||||
)
|
||||
);
|
||||
|
||||
$icon_style_group = calla_elated_add_admin_group(
|
||||
array(
|
||||
'parent' => $panel_dropdown_cart,
|
||||
'name' => 'dropdown_cart_icon_style_group',
|
||||
'title' => esc_html__( 'Dropdown Cart Icon Style', 'calla' ),
|
||||
'description' => esc_html__( 'Define styles for dropdown cart icon', 'calla' )
|
||||
)
|
||||
);
|
||||
|
||||
$icon_colors_row = calla_elated_add_admin_row(
|
||||
array(
|
||||
'parent' => $icon_style_group,
|
||||
'name' => 'icon_colors_row'
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'name' => 'dropdown_cart_icon_color',
|
||||
'type' => 'colorsimple',
|
||||
'label' => esc_html__( 'Icon Color', 'calla' ),
|
||||
'parent' => $icon_colors_row
|
||||
)
|
||||
);
|
||||
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'name' => 'dropdown_cart_hover_color',
|
||||
'type' => 'colorsimple',
|
||||
'label' => esc_html__( 'Icon Hover Color', 'calla' ),
|
||||
'parent' => $icon_colors_row
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'calla_elated_woocommerce_additional_options_map', 'calla_elated_woocommerce_dropdown_cart_options_map');
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'calla_elated_register_woocommerce_dropdown_cart_widget' ) ) {
|
||||
/**
|
||||
* Function that register dropdown cart widget
|
||||
*/
|
||||
function calla_elated_register_woocommerce_dropdown_cart_widget( $widgets ) {
|
||||
$widgets[] = 'CallaElatedWoocommerceDropdownCart';
|
||||
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
add_filter( 'calla_core_register_widgets', 'calla_elated_register_woocommerce_dropdown_cart_widget' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_get_dropdown_cart_icon_class' ) ) {
|
||||
/**
|
||||
* Returns dropdow cart icon class
|
||||
*/
|
||||
function calla_elated_get_dropdown_cart_icon_class() {
|
||||
$dropdown_cart_icon_source = calla_elated_options()->getOptionValue( 'dropdown_cart_icon_source' );
|
||||
|
||||
$dropdown_cart_icon_class_array = array(
|
||||
'eltdf-header-cart'
|
||||
);
|
||||
|
||||
$dropdown_cart_icon_class_array[] = $dropdown_cart_icon_source == 'icon_pack' ? 'eltdf-header-cart-icon-pack' : 'eltdf-header-cart-svg-path';
|
||||
|
||||
return $dropdown_cart_icon_class_array;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_get_dropdown_cart_icon_html' ) ) {
|
||||
/**
|
||||
* Returns dropdown cart icon HTML
|
||||
*/
|
||||
function calla_elated_get_dropdown_cart_icon_html() {
|
||||
$dropdown_cart_icon_source = calla_elated_options()->getOptionValue( 'dropdown_cart_icon_source' );
|
||||
$dropdown_cart_icon_pack = calla_elated_options()->getOptionValue( 'dropdown_cart_icon_pack' );
|
||||
$dropdown_cart_icon_svg_path = calla_elated_options()->getOptionValue( 'dropdown_cart_icon_svg_path' );
|
||||
|
||||
$dropdown_cart_icon_html = '';
|
||||
|
||||
if ( ( $dropdown_cart_icon_source == 'icon_pack' ) && ( isset( $dropdown_cart_icon_pack ) ) ) {
|
||||
$dropdown_cart_icon_html .= calla_elated_icon_collections()->getDropdownCartIcon( $dropdown_cart_icon_pack );
|
||||
} else if ( isset( $dropdown_cart_icon_svg_path ) ) {
|
||||
$dropdown_cart_icon_html .= $dropdown_cart_icon_svg_path;
|
||||
}
|
||||
|
||||
return $dropdown_cart_icon_html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/widgets/woocommerce-dropdown-cart/functions.php';
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/widgets/woocommerce-dropdown-cart/woocommerce-dropdown-cart.php';
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/widgets/woocommerce-dropdown-cart/admin/options-map/woocommerce-dropdown-cart-map.php';
|
||||
include_once ELATED_FRAMEWORK_MODULES_ROOT_DIR . '/woocommerce/widgets/woocommerce-dropdown-cart/admin/custom-styles/woocommerce-dropdown-cart-custom-styles.php';
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
if ( class_exists( 'CallaElatedWidget' ) ) {
|
||||
class CallaElatedWoocommerceDropdownCart extends CallaElatedWidget
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'eltdf_woocommerce_dropdown_cart',
|
||||
esc_html__('Elated Woocommerce Dropdown Cart', 'calla'),
|
||||
array('description' => esc_html__('Display a shop cart icon with a dropdown that shows products that are in the cart', 'calla'),)
|
||||
);
|
||||
|
||||
$this->setParams();
|
||||
}
|
||||
|
||||
protected function setParams()
|
||||
{
|
||||
|
||||
$this->params = array(
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'name' => 'woocommerce_dropdown_cart_margin',
|
||||
'title' => esc_html__('Icon Margin', 'calla'),
|
||||
'description' => esc_html__('Insert margin in format: top right bottom left (e.g. 10px 5px 10px 5px)', 'calla')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function widget($args, $instance)
|
||||
{
|
||||
extract($args);
|
||||
|
||||
global $woocommerce;
|
||||
|
||||
$icon_styles = array();
|
||||
|
||||
if ($instance['woocommerce_dropdown_cart_margin'] !== '') {
|
||||
$icon_styles[] = 'padding: ' . $instance['woocommerce_dropdown_cart_margin'];
|
||||
}
|
||||
|
||||
if ( $woocommerce->cart)
|
||||
$cart_is_empty = sizeof($woocommerce->cart->get_cart()) <= 0;
|
||||
else
|
||||
echo $cart_is_empty = false;
|
||||
|
||||
|
||||
$dropdown_cart_icon_class = calla_elated_get_dropdown_cart_icon_class();
|
||||
?>
|
||||
<div class="eltdf-shopping-cart-holder" <?php calla_elated_inline_style($icon_styles) ?>>
|
||||
<div class="eltdf-shopping-cart-inner">
|
||||
<a itemprop="url" <?php calla_elated_class_attribute($dropdown_cart_icon_class); ?>
|
||||
href="<?php echo esc_url(wc_get_cart_url()); ?>">
|
||||
<span class="eltdf-cart-icon"><?php echo calla_elated_get_dropdown_cart_icon_html(); ?></span>
|
||||
</a>
|
||||
<div class="eltdf-shopping-cart-dropdown">
|
||||
<ul>
|
||||
<?php if ($cart_is_empty) : ?>
|
||||
<?php foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) :
|
||||
$_product = $cart_item['data'];
|
||||
// Only display if allowed
|
||||
if (!$_product->exists() || $cart_item['quantity'] == 0) {
|
||||
continue;
|
||||
}
|
||||
// Get price
|
||||
$product_price = get_option('woocommerce_tax_display_cart') == 'excl' ? wc_get_price_excluding_tax($_product) : wc_get_price_including_tax($_product);
|
||||
?>
|
||||
<li>
|
||||
<div class="eltdf-item-image-holder">
|
||||
<a itemprop="url"
|
||||
href="<?php echo esc_url(get_permalink($cart_item['product_id'])); ?>">
|
||||
<?php echo wp_kses($_product->get_image(), array(
|
||||
'img' => array(
|
||||
'src' => true,
|
||||
'width' => true,
|
||||
'height' => true,
|
||||
'class' => true,
|
||||
'alt' => true,
|
||||
'title' => true,
|
||||
'id' => true
|
||||
)
|
||||
)); ?>
|
||||
</a>
|
||||
</div>
|
||||
<div class="eltdf-item-info-holder">
|
||||
<span itemprop="name" class="eltdf-product-title">
|
||||
<a itemprop="url"
|
||||
href="<?php echo esc_url(get_permalink($cart_item['product_id'])); ?>"><?php echo apply_filters('calla_elated_woo_widget_cart_product_title', $_product->get_name(), $_product); ?></a>
|
||||
</span>
|
||||
<?php if (apply_filters('calla_elated_woo_cart_enable_quantity', true)) { ?>
|
||||
<span class="eltdf-quantity">Ilość: <?php echo esc_html($cart_item['quantity']); ?></span>
|
||||
<?php } ?>
|
||||
<?php echo apply_filters('calla_elated_woo_cart_item_price_html', wc_price($product_price), $cart_item, $cart_item_key); ?>
|
||||
<?php echo apply_filters('calla_elated_woo_cart_item_remove_link', sprintf('<a href="%s" class="remove" title="%s"><span class="icon-arrows-remove"></span></a>', esc_url(wc_get_cart_remove_url($cart_item_key)), esc_attr__('Remove this item', 'calla')), $cart_item_key); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<li class="eltdf-cart-bottom">
|
||||
<div class="eltdf-subtotal-holder clearfix">
|
||||
<span class="eltdf-total">Razem</span>
|
||||
<span class="eltdf-total-amount">
|
||||
<?php echo wp_kses($woocommerce->cart->get_cart_subtotal(), array(
|
||||
'span' => array(
|
||||
'class' => true,
|
||||
'id' => true
|
||||
)
|
||||
)); ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="eltdf-btn-holder clearfix">
|
||||
<a itemprop="url" href="<?php echo esc_url(wc_get_cart_url()); ?>" class="eltdf-view-cart">Zobacz koszyk</a>
|
||||
</div>
|
||||
</li>
|
||||
<?php else : ?>
|
||||
<li class="eltdf-empty-cart"><?php esc_html_e('No products in the cart.', 'calla'); ?></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_filter('woocommerce_add_to_cart_fragments', 'calla_elated_woocommerce_header_add_to_cart_fragment');
|
||||
|
||||
function calla_elated_woocommerce_header_add_to_cart_fragment($fragments) {
|
||||
global $woocommerce;
|
||||
|
||||
ob_start();
|
||||
|
||||
$cart_is_empty = sizeof($woocommerce->cart->get_cart()) <= 0;
|
||||
|
||||
$dropdown_cart_icon_class = calla_elated_get_dropdown_cart_icon_class();
|
||||
|
||||
?>
|
||||
<div class="eltdf-shopping-cart-inner">
|
||||
<a itemprop="url" <?php calla_elated_class_attribute( $dropdown_cart_icon_class ); ?> href="<?php echo esc_url(wc_get_cart_url()); ?>">
|
||||
<span class="eltdf-cart-icon"><?php echo calla_elated_get_dropdown_cart_icon_html(); ?></span>
|
||||
</a>
|
||||
<div class="eltdf-shopping-cart-dropdown">
|
||||
<ul>
|
||||
<?php if (!$cart_is_empty) : ?>
|
||||
<?php foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) :
|
||||
$_product = $cart_item['data'];
|
||||
// Only display if allowed
|
||||
if (!$_product->exists() || $cart_item['quantity'] == 0) {
|
||||
continue;
|
||||
}
|
||||
// Get price
|
||||
$product_price = get_option( 'woocommerce_tax_display_cart' ) == 'excl' ? wc_get_price_excluding_tax( $_product ) : wc_get_price_including_tax( $_product );
|
||||
?>
|
||||
<li>
|
||||
<div class="eltdf-item-image-holder">
|
||||
<a itemprop="url" href="<?php echo esc_url(get_permalink($cart_item['product_id'])); ?>">
|
||||
<?php echo wp_kses($_product->get_image(), array(
|
||||
'img' => array(
|
||||
'src' => true,
|
||||
'width' => true,
|
||||
'height' => true,
|
||||
'class' => true,
|
||||
'alt' => true,
|
||||
'title' => true,
|
||||
'id' => true
|
||||
)
|
||||
)); ?>
|
||||
</a>
|
||||
</div>
|
||||
<div class="eltdf-item-info-holder">
|
||||
<span itemprop="name" class="eltdf-product-title">
|
||||
<a itemprop="url" href="<?php echo esc_url(get_permalink($cart_item['product_id'])); ?>"><?php echo apply_filters('calla_elated_woo_widget_cart_product_title', $_product->get_name(), $_product); ?></a>
|
||||
</span>
|
||||
<?php if(apply_filters('calla_elated_woo_cart_enable_quantity', true)) { ?>
|
||||
<span class="eltdf-quantity">Ilość: <?php echo esc_html($cart_item['quantity']); ?></span>
|
||||
<?php } ?>
|
||||
<?php echo apply_filters('calla_elated_woo_cart_item_price_html', wc_price($product_price), $cart_item, $cart_item_key); ?>
|
||||
<?php echo apply_filters('calla_elated_woo_cart_item_remove_link', sprintf('<a href="%s" class="remove" title="%s"><span class="icon-arrows-remove"></span></a>', esc_url( wc_get_cart_remove_url( $cart_item_key ) ), esc_html__('Remove this item', 'calla')), $cart_item_key); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<li class="eltdf-cart-bottom">
|
||||
<div class="eltdf-subtotal-holder clearfix">
|
||||
<span class="eltdf-total">Razem</span>
|
||||
<span class="eltdf-total-amount">
|
||||
<?php echo wp_kses($woocommerce->cart->get_cart_subtotal(), array(
|
||||
'span' => array(
|
||||
'class' => true,
|
||||
'id' => true
|
||||
)
|
||||
)); ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="eltdf-btn-holder clearfix">
|
||||
<a itemprop="url" href="<?php echo esc_url(wc_get_cart_url()); ?>" class="eltdf-view-cart">Zobacz koszyk</a>
|
||||
</div>
|
||||
</li>
|
||||
<?php else : ?>
|
||||
<li class="eltdf-empty-cart"><?php esc_html_e('No products in the cart.', 'calla'); ?></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$fragments['div.eltdf-shopping-cart-inner'] = ob_get_clean();
|
||||
|
||||
return $fragments;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,228 @@
|
||||
<?php
|
||||
|
||||
// Adds theme support for WooCommerce
|
||||
add_theme_support( 'woocommerce' );
|
||||
|
||||
// Disable the default WooCommerce stylesheet
|
||||
add_filter( 'woocommerce_enqueue_styles', '__return_false' );
|
||||
|
||||
if ( ! function_exists( 'calla_elated_disable_woocommerce_pretty_photo' ) ) {
|
||||
/**
|
||||
* Function that disable WooCommerce pretty photo script and style
|
||||
*/
|
||||
function calla_elated_disable_woocommerce_pretty_photo() {
|
||||
if ( calla_elated_load_woo_assets() ) {
|
||||
|
||||
wp_deregister_style( 'woocommerce_prettyPhoto_css' );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'calla_elated_disable_woocommerce_pretty_photo' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_content' ) ) {
|
||||
/**
|
||||
* Output WooCommerce content.
|
||||
*
|
||||
* This function is only used in the optional 'woocommerce.php' template
|
||||
* which people can add to their themes to add basic woocommerce support
|
||||
* without hooks or modifying core templates.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function calla_elated_woocommerce_content() {
|
||||
|
||||
if ( is_singular( 'product' ) ) {
|
||||
|
||||
while ( have_posts() ) : the_post();
|
||||
|
||||
wc_get_template_part( 'content', 'single-product' );
|
||||
|
||||
endwhile;
|
||||
|
||||
} else {
|
||||
|
||||
if ( have_posts() ) :
|
||||
|
||||
/**
|
||||
* woocommerce_before_shop_loop hook.
|
||||
*
|
||||
* @hooked woocommerce_result_count - 20
|
||||
* @hooked woocommerce_catalog_ordering - 30
|
||||
*/
|
||||
do_action( 'woocommerce_before_shop_loop' );
|
||||
|
||||
woocommerce_product_loop_start();
|
||||
|
||||
woocommerce_product_subcategories();
|
||||
|
||||
while ( have_posts() ) : the_post();
|
||||
|
||||
wc_get_template_part( 'content', 'product' );
|
||||
|
||||
endwhile; // end of the loop.
|
||||
|
||||
woocommerce_product_loop_end();
|
||||
|
||||
/**
|
||||
* woocommerce_after_shop_loop hook.
|
||||
*
|
||||
* @hooked woocommerce_pagination - 10
|
||||
*/
|
||||
do_action( 'woocommerce_after_shop_loop' );
|
||||
|
||||
elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) :
|
||||
|
||||
wc_get_template( 'loop/no-products-found.php' );
|
||||
|
||||
endif;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*************** GENERAL FILTERS - begin ***************/
|
||||
|
||||
//Add additional html tags around woocommerce pagination
|
||||
add_action('woocommerce_after_shop_loop', 'calla_elated_woo_view_all_pagination_additional_tag_before', 9);
|
||||
add_action('woocommerce_after_shop_loop', 'calla_elated_woo_view_all_pagination_additional_tag_after', 12);
|
||||
|
||||
|
||||
/*************** GENERAL FILTERS - end ***************/
|
||||
|
||||
/*************** PRODUCT LISTS FILTERS - begin ***************/
|
||||
|
||||
//Add additional html tags around product lists
|
||||
add_action( 'woocommerce_before_shop_loop', 'calla_elated_pl_holder_additional_tag_before', 35 );
|
||||
add_action( 'woocommerce_after_shop_loop', 'calla_elated_pl_holder_additional_tag_after', 5 );
|
||||
|
||||
//Add additional html tag around product elements
|
||||
add_action( 'woocommerce_before_shop_loop_item', 'calla_elated_pl_inner_additional_tag_before', 5 );
|
||||
|
||||
//Remove open and close link position
|
||||
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
|
||||
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 );
|
||||
|
||||
//Add additional html tags around image and marks
|
||||
add_action( 'woocommerce_before_shop_loop_item_title', 'calla_elated_pl_image_additional_tag_before', 5 );
|
||||
add_action( 'calla_elated_woo_pl_info_below_image', 'calla_elated_pl_image_additional_tag_after', 6 );
|
||||
add_action( 'calla_elated_woo_pl_info_on_image_hover', 'calla_elated_pl_image_additional_tag_after', 1 );
|
||||
|
||||
|
||||
/*************** Product Info Position Is On Image Hover ***************/
|
||||
|
||||
//Add additional html tag around product elements
|
||||
add_action( 'calla_elated_woo_pl_info_on_image_hover', 'calla_elated_pl_inner_additional_tag_after', 22 );
|
||||
|
||||
//Add open and close link position
|
||||
add_action( 'calla_elated_woo_pl_info_on_image_hover', 'woocommerce_template_loop_product_link_open', 21 );
|
||||
add_action( 'calla_elated_woo_pl_info_on_image_hover', 'woocommerce_template_loop_product_link_close', 21 );
|
||||
|
||||
//Add additional html around product info elements
|
||||
add_action( 'calla_elated_woo_pl_info_on_image_hover', 'calla_elated_pl_inner_text_additional_tag_before', 5 );
|
||||
add_action( 'calla_elated_woo_pl_info_on_image_hover', 'calla_elated_pl_inner_text_additional_tag_after', 15 );
|
||||
|
||||
//Override product title with our own html
|
||||
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
|
||||
add_action( 'calla_elated_woo_pl_info_on_image_hover', 'calla_elated_woocommerce_template_loop_product_title', 7 );
|
||||
|
||||
//Add additional html tags around rating star element
|
||||
add_action( 'calla_elated_woo_pl_info_on_image_hover', 'calla_elated_pl_rating_additional_tag_before', 9 );
|
||||
add_action( 'calla_elated_woo_pl_info_on_image_hover', 'calla_elated_pl_rating_additional_tag_after', 11 );
|
||||
|
||||
//Change rating star position
|
||||
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
|
||||
add_action( 'calla_elated_woo_pl_info_on_image_hover', 'woocommerce_template_loop_rating', 10 );
|
||||
|
||||
//Change price position
|
||||
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
|
||||
add_action( 'calla_elated_woo_pl_info_on_image_hover', 'woocommerce_template_loop_price', 12 );
|
||||
|
||||
//Change add to cart position
|
||||
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
|
||||
add_action( 'calla_elated_woo_pl_info_on_image_hover', 'woocommerce_template_loop_add_to_cart', 13 );
|
||||
|
||||
|
||||
/*************** Product Info Position Is Below Image ***************/
|
||||
|
||||
//Add additional html tag around product elements
|
||||
add_action( 'calla_elated_woo_pl_info_below_image', 'calla_elated_pl_inner_additional_tag_after', 21 );
|
||||
|
||||
//Add open and close link position
|
||||
add_action( 'calla_elated_woo_pl_info_below_image', 'woocommerce_template_loop_product_link_open', 20 );
|
||||
add_action( 'calla_elated_woo_pl_info_below_image', 'woocommerce_template_loop_product_link_close', 20 );
|
||||
|
||||
//Add additional html at the end of product info elements
|
||||
add_action( 'calla_elated_woo_pl_info_below_image', 'calla_elated_pl_text_wrapper_additional_tag_before', 22 );
|
||||
add_action( 'calla_elated_woo_pl_info_below_image', 'calla_elated_pl_text_wrapper_additional_tag_after', 30 );
|
||||
|
||||
//Override product title with our own html
|
||||
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
|
||||
add_action( 'calla_elated_woo_pl_info_below_image', 'calla_elated_woocommerce_template_loop_product_title', 23 );
|
||||
|
||||
//Change rating star position
|
||||
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
|
||||
//add_action( 'calla_elated_woo_pl_info_below_image', 'woocommerce_template_loop_rating', 25 );
|
||||
|
||||
//Add additional html tags around rating star element
|
||||
//add_action( 'calla_elated_woo_pl_info_below_image', 'calla_elated_pl_rating_additional_tag_before', 24 );
|
||||
//add_action( 'calla_elated_woo_pl_info_below_image', 'calla_elated_pl_rating_additional_tag_after', 26 );
|
||||
|
||||
//Change price position
|
||||
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
|
||||
add_action( 'calla_elated_woo_pl_info_below_image', 'woocommerce_template_loop_price', 27 );
|
||||
|
||||
//Add additional html around add to cart element
|
||||
add_action( 'calla_elated_woo_pl_info_below_image', 'calla_elated_pl_inner_text_additional_tag_before', 1 );
|
||||
add_action( 'calla_elated_woo_pl_info_below_image', 'calla_elated_pl_inner_text_additional_tag_after', 3 );
|
||||
|
||||
//Change add to cart position
|
||||
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
|
||||
add_action( 'calla_elated_woo_pl_info_below_image', 'woocommerce_template_loop_add_to_cart', 2 );
|
||||
|
||||
|
||||
/*************** PRODUCT LISTS FILTERS - end ***************/
|
||||
|
||||
/*************** PRODUCT SINGLE FILTERS - begin ***************/
|
||||
|
||||
//Add additional html around single product summary and images
|
||||
add_action( 'woocommerce_before_single_product_summary', 'calla_elated_single_product_content_additional_tag_before', 5 );
|
||||
add_action( 'woocommerce_after_single_product_summary', 'calla_elated_single_product_content_additional_tag_after', 1 );
|
||||
|
||||
//Add additional html around single product summary
|
||||
add_action( 'woocommerce_before_single_product_summary', 'calla_elated_single_product_summary_additional_tag_before', 30 );
|
||||
add_action( 'woocommerce_after_single_product_summary', 'calla_elated_single_product_summary_additional_tag_after', 5 );
|
||||
|
||||
//Override product single thumbnails with our own html
|
||||
remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
|
||||
add_action( 'woocommerce_product_thumbnails', 'calla_elated_single_product_show_product_thumbnails', 19 );
|
||||
|
||||
//Change sale mark position
|
||||
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
|
||||
add_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_sale_flash', 20 );
|
||||
|
||||
//Change title position
|
||||
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
|
||||
add_action( 'woocommerce_single_product_summary', 'calla_elated_woocommerce_template_single_title', 5 );
|
||||
|
||||
//Change price position
|
||||
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
|
||||
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 8 );
|
||||
|
||||
//Change add to cart position
|
||||
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
|
||||
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 22 );
|
||||
|
||||
//Change product meta position
|
||||
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
|
||||
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 25 );
|
||||
|
||||
//Add social share (default woocommerce_share)
|
||||
add_action( 'woocommerce_single_product_summary', 'calla_elated_woocommerce_share', 28 );
|
||||
|
||||
//Change product tabs position
|
||||
// remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
|
||||
// add_action( 'woocommerce_single_product_summary', 'woocommerce_output_product_data_tabs', 30 );
|
||||
|
||||
|
||||
/*************** PRODUCT SINGLE FILTERS - end ***************/
|
||||
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
/**
|
||||
* Woocommerce helper functions
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_meta_box_functions' ) ) {
|
||||
function calla_elated_woocommerce_meta_box_functions( $post_types ) {
|
||||
$post_types[] = 'product';
|
||||
|
||||
return $post_types;
|
||||
}
|
||||
|
||||
add_filter( 'calla_elated_meta_box_post_types_save', 'calla_elated_woocommerce_meta_box_functions' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_add_social_share_option' ) ) {
|
||||
function calla_elated_woocommerce_add_social_share_option( $container ) {
|
||||
if ( calla_elated_is_woocommerce_installed() ) {
|
||||
calla_elated_add_admin_field(
|
||||
array(
|
||||
'type' => 'yesno',
|
||||
'name' => 'enable_social_share_on_product',
|
||||
'default_value' => 'no',
|
||||
'label' => esc_html__( 'Product', 'calla' ),
|
||||
'description' => esc_html__( 'Show Social Share for Product Items', 'calla' ),
|
||||
'parent' => $container
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'calla_elated_post_types_social_share', 'calla_elated_woocommerce_add_social_share_option', 10, 1 );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_style_dynamics_deps' ) ) {
|
||||
function calla_elated_woocommerce_style_dynamics_deps( $deps ) {
|
||||
$style_dynamic_deps_array = array();
|
||||
if ( calla_elated_is_woocommerce_installed() && calla_elated_load_woo_assets() ) {
|
||||
$style_dynamic_deps_array[] = 'calla-elated-woo';
|
||||
if (calla_elated_is_responsive_on()) {
|
||||
$style_dynamic_deps_array[] = 'calla-elated-woo-responsive';
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge($deps, $style_dynamic_deps_array);
|
||||
}
|
||||
|
||||
add_filter('calla_elated_style_dynamic_deps','calla_elated_woocommerce_style_dynamics_deps');
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_get_woo_shortcode_module_template_part' ) ) {
|
||||
/**
|
||||
* Loads module template part.
|
||||
*
|
||||
* @param string $template name of the template to load
|
||||
* @param string $module name of the module folder
|
||||
* @param string $slug
|
||||
* @param array $params array of parameters to pass to template
|
||||
* @param array $additional_params array of additional parameters to pass to template
|
||||
*
|
||||
* @return html
|
||||
* @see calla_elated_get_template_part()
|
||||
*/
|
||||
function calla_elated_get_woo_shortcode_module_template_part( $template, $module, $slug = '', $params = array(), $additional_params = array() ) {
|
||||
|
||||
//HTML Content from template
|
||||
$html = '';
|
||||
$template_path = 'framework/modules/woocommerce/shortcodes/' . $module;
|
||||
|
||||
$temp = $template_path . '/' . $template;
|
||||
|
||||
if ( is_array( $params ) && count( $params ) ) {
|
||||
extract( $params );
|
||||
}
|
||||
|
||||
if ( is_array( $additional_params ) && count( $additional_params ) ) {
|
||||
extract( $additional_params );
|
||||
}
|
||||
|
||||
$templates = array();
|
||||
|
||||
if ( $temp !== '' ) {
|
||||
if ( $slug !== '' ) {
|
||||
$templates[] = "{$temp}-{$slug}.php";
|
||||
}
|
||||
|
||||
$templates[] = $temp . '.php';
|
||||
}
|
||||
$located = calla_elated_find_template_path( $templates );
|
||||
if ( $located ) {
|
||||
ob_start();
|
||||
include( $located );
|
||||
$html = ob_get_clean();
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_is_woocommerce_page' ) ) {
|
||||
/**
|
||||
* Function that checks if current page is woocommerce shop, product or product taxonomy
|
||||
* @return bool
|
||||
*
|
||||
* @see is_woocommerce()
|
||||
*/
|
||||
function calla_elated_is_woocommerce_page() {
|
||||
if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) {
|
||||
return is_woocommerce();
|
||||
} elseif ( function_exists( 'is_cart' ) && is_cart() ) {
|
||||
return is_cart();
|
||||
} elseif ( function_exists( 'is_checkout' ) && is_checkout() ) {
|
||||
return is_checkout();
|
||||
} elseif ( function_exists( 'is_account_page' ) && is_account_page() ) {
|
||||
return is_account_page();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_is_woocommerce_shop' ) ) {
|
||||
/**
|
||||
* Function that checks if current page is shop or product page
|
||||
* @return bool
|
||||
*
|
||||
* @see is_shop()
|
||||
*/
|
||||
function calla_elated_is_woocommerce_shop() {
|
||||
return function_exists( 'is_shop' ) && ( is_shop() || is_product() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_get_woo_shop_page_id' ) ) {
|
||||
/**
|
||||
* Function that returns shop page id that is set in WooCommerce settings page
|
||||
* @return int id of shop page
|
||||
*/
|
||||
function calla_elated_get_woo_shop_page_id() {
|
||||
if ( calla_elated_is_woocommerce_installed() ) {
|
||||
//get shop page id from options table
|
||||
$shop_id = get_option( 'woocommerce_shop_page_id' );
|
||||
$page_id = ! empty( $shop_id ) ? $shop_id : '-1';
|
||||
|
||||
return $page_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_is_product_category' ) ) {
|
||||
function calla_elated_is_product_category() {
|
||||
return function_exists( 'is_product_category' ) && is_product_category();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_is_product_tag' ) ) {
|
||||
function calla_elated_is_product_tag() {
|
||||
return function_exists( 'is_product_tag' ) && is_product_tag();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_load_woo_assets' ) ) {
|
||||
/**
|
||||
* Function that checks whether WooCommerce assets needs to be loaded.
|
||||
*
|
||||
* @see calla_elated_is_woocommerce_page()
|
||||
* @see calla_elated_has_woocommerce_shortcode()
|
||||
* @see calla_elated_has_woocommerce_widgets()
|
||||
* @return bool
|
||||
*/
|
||||
function calla_elated_load_woo_assets() {
|
||||
return calla_elated_is_woocommerce_installed() && ( calla_elated_is_woocommerce_page() || calla_elated_has_woocommerce_shortcode() || calla_elated_has_woocommerce_widgets() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_return_woocommerce_global_variable' ) ) {
|
||||
function calla_elated_return_woocommerce_global_variable() {
|
||||
if ( calla_elated_is_woocommerce_installed() ) {
|
||||
global $product;
|
||||
|
||||
return $product;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_has_woocommerce_shortcode' ) ) {
|
||||
/**
|
||||
* Function that checks if current page has at least one of WooCommerce shortcodes added
|
||||
* @return bool
|
||||
*/
|
||||
function calla_elated_has_woocommerce_shortcode() {
|
||||
$woocommerce_shortcodes = array(
|
||||
'add_to_cart',
|
||||
'add_to_cart_url',
|
||||
'product_page',
|
||||
'product',
|
||||
'products',
|
||||
'product_categories',
|
||||
'product_category',
|
||||
'recent_products',
|
||||
'featured_products',
|
||||
'sale_products',
|
||||
'best_selling_products',
|
||||
'top_rated_products',
|
||||
'product_attribute',
|
||||
'related_products',
|
||||
'woocommerce_messages',
|
||||
'woocommerce_cart',
|
||||
'woocommerce_checkout',
|
||||
'woocommerce_order_tracking',
|
||||
'woocommerce_my_account',
|
||||
'woocommerce_edit_address',
|
||||
'woocommerce_change_password',
|
||||
'woocommerce_view_order',
|
||||
'woocommerce_pay',
|
||||
'woocommerce_thankyou'
|
||||
);
|
||||
|
||||
$woocommerce_shortcodes = apply_filters( 'calla_elated_woocommerce_shortcodes_list', $woocommerce_shortcodes );
|
||||
|
||||
foreach ( $woocommerce_shortcodes as $woocommerce_shortcode ) {
|
||||
$has_shortcode = calla_elated_has_shortcode( $woocommerce_shortcode );
|
||||
|
||||
if ( $has_shortcode ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_has_woocommerce_widgets' ) ) {
|
||||
/**
|
||||
* Function that checks if current page has at least one of WooCommerce shortcodes added
|
||||
* @return bool
|
||||
*/
|
||||
function calla_elated_has_woocommerce_widgets() {
|
||||
$widgets_array = array(
|
||||
'eltdf_woocommerce_dropdown_cart',
|
||||
'woocommerce_widget_cart',
|
||||
'woocommerce_layered_nav',
|
||||
'woocommerce_layered_nav_filters',
|
||||
'woocommerce_price_filter',
|
||||
'woocommerce_product_categories',
|
||||
'woocommerce_product_search',
|
||||
'woocommerce_product_tag_cloud',
|
||||
'woocommerce_products',
|
||||
'woocommerce_recent_reviews',
|
||||
'woocommerce_recently_viewed_products',
|
||||
'woocommerce_top_rated_products'
|
||||
);
|
||||
|
||||
$widgets_array = apply_filters( 'calla_elated_woocommerce_widgets_list', $widgets_array );
|
||||
|
||||
foreach ( $widgets_array as $widget ) {
|
||||
$active_widget = is_active_widget( false, false, $widget );
|
||||
|
||||
if ( $active_widget ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_add_product_to_search_types' ) ) {
|
||||
function calla_elated_add_product_to_search_types( $post_types ) {
|
||||
$post_types['product'] = esc_html__( 'Product', 'calla' );
|
||||
|
||||
return $post_types;
|
||||
}
|
||||
|
||||
add_filter( 'calla_elated_search_post_type_widget_params_post_type', 'calla_elated_add_product_to_search_types' );
|
||||
}
|
||||
@@ -0,0 +1,674 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_body_class' ) ) {
|
||||
function calla_elated_woocommerce_body_class( $classes ) {
|
||||
if ( calla_elated_is_woocommerce_page() ) {
|
||||
$classes[] = 'eltdf-woocommerce-page';
|
||||
|
||||
if ( function_exists( 'is_shop' ) && is_shop() ) {
|
||||
$classes[] = 'eltdf-woo-main-page';
|
||||
}
|
||||
|
||||
if ( is_singular( 'product' ) ) {
|
||||
$classes[] = 'eltdf-woo-single-page';
|
||||
}
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
add_filter( 'body_class', 'calla_elated_woocommerce_body_class' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_columns_class' ) ) {
|
||||
function calla_elated_woocommerce_columns_class( $classes ) {
|
||||
|
||||
if ( is_singular( 'product' ) ) {
|
||||
$classes[] = calla_elated_options()->getOptionValue( 'eltdf_woo_related_products_columns' );
|
||||
} else {
|
||||
$classes[] = calla_elated_options()->getOptionValue( 'eltdf_woo_product_list_columns' );
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
add_filter( 'body_class', 'calla_elated_woocommerce_columns_class' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_columns_space_class' ) ) {
|
||||
function calla_elated_woocommerce_columns_space_class( $classes ) {
|
||||
$woo_space_between_items = calla_elated_options()->getOptionValue( 'eltdf_woo_product_list_columns_space' );
|
||||
|
||||
if ( ! empty( $woo_space_between_items ) ) {
|
||||
$classes[] = 'eltdf-woo-' . $woo_space_between_items . '-space';
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
add_filter( 'body_class', 'calla_elated_woocommerce_columns_space_class' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_pl_info_position_class' ) ) {
|
||||
function calla_elated_woocommerce_pl_info_position_class( $classes ) {
|
||||
$info_position = calla_elated_options()->getOptionValue( 'eltdf_woo_product_list_info_position' );
|
||||
$info_position_class = '';
|
||||
|
||||
if ( $info_position === 'info_below_image' ) {
|
||||
$info_position_class = 'eltdf-woo-pl-info-below-image';
|
||||
} else if ( $info_position === 'info_on_image_hover' ) {
|
||||
$info_position_class = 'eltdf-woo-pl-info-on-image-hover';
|
||||
}
|
||||
|
||||
$classes[] = $info_position_class;
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
add_filter( 'body_class', 'calla_elated_woocommerce_pl_info_position_class' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_add_woocommerce_shortcode_class' ) ) {
|
||||
/**
|
||||
* Function that checks if current page has at least one of WooCommerce shortcodes added
|
||||
* @return string
|
||||
*/
|
||||
function calla_elated_add_woocommerce_shortcode_class( $classes ) {
|
||||
$woocommerce_shortcodes = array(
|
||||
'woocommerce_order_tracking'
|
||||
);
|
||||
|
||||
foreach ( $woocommerce_shortcodes as $woocommerce_shortcode ) {
|
||||
$has_shortcode = calla_elated_has_shortcode( $woocommerce_shortcode );
|
||||
|
||||
if ( $has_shortcode ) {
|
||||
$classes[] = 'eltdf-woocommerce-page woocommerce-account eltdf-' . str_replace( '_', '-', $woocommerce_shortcode );
|
||||
}
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
add_filter( 'body_class', 'calla_elated_add_woocommerce_shortcode_class' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woo_single_product_thumb_position_class' ) ) {
|
||||
function calla_elated_woo_single_product_thumb_position_class( $classes ) {
|
||||
$product_thumbnail_position = calla_elated_get_meta_field_intersect( 'woo_set_thumb_images_position' );
|
||||
|
||||
if ( ! empty( $product_thumbnail_position ) ) {
|
||||
$classes[] = 'eltdf-woo-single-thumb-' . $product_thumbnail_position;
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
add_filter( 'body_class', 'calla_elated_woo_single_product_thumb_position_class' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woo_single_product_has_zoom_class' ) ) {
|
||||
function calla_elated_woo_single_product_has_zoom_class( $classes ) {
|
||||
$zoom_maginifier = calla_elated_get_meta_field_intersect( 'woo_enable_single_product_zoom_image' );
|
||||
|
||||
if ( $zoom_maginifier === 'yes' ) {
|
||||
$classes[] = 'eltdf-woo-single-has-zoom';
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
add_filter( 'body_class', 'calla_elated_woo_single_product_has_zoom_class' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woo_single_product_has_zoom_support' ) ) {
|
||||
function calla_elated_woo_single_product_has_zoom_support() {
|
||||
$zoom_maginifier = calla_elated_get_meta_field_intersect( 'woo_enable_single_product_zoom_image' );
|
||||
|
||||
if ( $zoom_maginifier === 'yes' ) {
|
||||
add_theme_support( 'wc-product-gallery-zoom' );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'init', 'calla_elated_woo_single_product_has_zoom_support' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woo_single_product_image_behavior_class' ) ) {
|
||||
function calla_elated_woo_single_product_image_behavior_class( $classes ) {
|
||||
$image_behavior = calla_elated_get_meta_field_intersect( 'woo_set_single_images_behavior' );
|
||||
|
||||
if ( ! empty( $image_behavior ) ) {
|
||||
$classes[] = 'eltdf-woo-single-has-' . $image_behavior;
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
add_filter( 'body_class', 'calla_elated_woo_single_product_image_behavior_class' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woo_single_product_photo_swipe_support' ) ) {
|
||||
function calla_elated_woo_single_product_photo_swipe_support() {
|
||||
$image_behavior = calla_elated_get_meta_field_intersect( 'woo_set_single_images_behavior' );
|
||||
|
||||
if ( $image_behavior === 'photo-swipe' ) {
|
||||
add_theme_support( 'wc-product-gallery-lightbox' );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'init', 'calla_elated_woo_single_product_photo_swipe_support' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_products_per_page' ) ) {
|
||||
/**
|
||||
* Function that sets number of products per page. Default is 9
|
||||
* @return int number of products to be shown per page
|
||||
*/
|
||||
function calla_elated_woocommerce_products_per_page() {
|
||||
$products_per_page_meta = calla_elated_options()->getOptionValue( 'eltdf_woo_products_per_page' );
|
||||
$products_per_page = ! empty( $products_per_page_meta ) ? intval( $products_per_page_meta ) : 12;
|
||||
|
||||
if ( isset( $_GET['woo-products-count'] ) && $_GET['woo-products-count'] === 'view-all' ) {
|
||||
$products_per_page = 9999;
|
||||
}
|
||||
|
||||
return $products_per_page;
|
||||
}
|
||||
|
||||
add_filter('loop_shop_per_page', 'calla_elated_woocommerce_products_per_page', 20);
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_related_products_args' ) ) {
|
||||
/**
|
||||
* Function that sets number of displayed related products. Hooks to woocommerce_output_related_products_args filter
|
||||
*
|
||||
* @param $args array array of args for the query
|
||||
*
|
||||
* @return mixed array of changed args
|
||||
*/
|
||||
function calla_elated_woocommerce_related_products_args( $args ) {
|
||||
$related = calla_elated_options()->getOptionValue( 'eltdf_woo_related_products_columns' );
|
||||
|
||||
if ( ! empty( $related ) ) {
|
||||
switch ( $related ) {
|
||||
case 'eltdf-woocommerce-columns-4':
|
||||
$args['posts_per_page'] = 4;
|
||||
break;
|
||||
case 'eltdf-woocommerce-columns-3':
|
||||
$args['posts_per_page'] = 3;
|
||||
break;
|
||||
default:
|
||||
$args['posts_per_page'] = 3;
|
||||
}
|
||||
} else {
|
||||
$args['posts_per_page'] = 4;
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
add_filter('woocommerce_output_related_products_args', 'calla_elated_woocommerce_related_products_args');
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_product_thumbnail_column_size' ) ) {
|
||||
/**
|
||||
* Function that sets number of thumbnails on single product page per row. Default is 4
|
||||
* @return int number of thumbnails to be shown on single product page per row
|
||||
*/
|
||||
function calla_elated_woocommerce_product_thumbnail_column_size() {
|
||||
$thumbs_number_meta = calla_elated_options()->getOptionValue( 'woo_number_of_thumb_images' );
|
||||
$thumbs_number = ! empty ( $thumbs_number_meta ) ? intval( $thumbs_number_meta ) : 4;
|
||||
|
||||
return apply_filters( 'calla_elated_number_of_thumbnails_per_row_single_product', $thumbs_number );
|
||||
}
|
||||
|
||||
add_filter( 'woocommerce_product_thumbnails_columns', 'calla_elated_woocommerce_product_thumbnail_column_size', 10 );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_single_product_show_product_thumbnails' ) ) {
|
||||
function calla_elated_single_product_show_product_thumbnails() {
|
||||
global $product;
|
||||
|
||||
$attachment_ids = $product->get_gallery_image_ids();
|
||||
|
||||
if ( $attachment_ids && has_post_thumbnail() ) {
|
||||
foreach ( $attachment_ids as $attachment_id ) {
|
||||
$full_size_image = wp_get_attachment_image_src( $attachment_id, 'full' );
|
||||
$thumbnail = wp_get_attachment_image_src( $attachment_id, 'woocommerce_thumbnail' );
|
||||
$attributes = array(
|
||||
'title' => get_post_field( 'post_title', $attachment_id ),
|
||||
'data-caption' => get_post_field( 'post_excerpt', $attachment_id ),
|
||||
'data-src' => $full_size_image[0],
|
||||
'data-large_image' => $full_size_image[0],
|
||||
'data-large_image_width' => $full_size_image[1],
|
||||
'data-large_image_height' => $full_size_image[2],
|
||||
);
|
||||
|
||||
$html = '<div data-thumb="' . esc_url( $thumbnail[0] ) . '" class="woocommerce-product-gallery__image"><a href="' . esc_url( $full_size_image[0] ) . '">';
|
||||
$html .= wp_get_attachment_image( $attachment_id, 'woocommerce_thumbnail', false, $attributes );
|
||||
$html .= '</a></div>';
|
||||
|
||||
echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, $attachment_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_template_loop_product_title' ) ) {
|
||||
/**
|
||||
* Function for overriding product title template in Product List Loop
|
||||
*/
|
||||
function calla_elated_woocommerce_template_loop_product_title() {
|
||||
$tag = calla_elated_options()->getOptionValue( 'eltdf_products_list_title_tag' );
|
||||
if ( $tag === '' ) {
|
||||
$tag = 'h6';
|
||||
}
|
||||
|
||||
the_title( '<' . $tag . ' class="eltdf-product-list-title"><a href="' . get_the_permalink() . '">', '</a></' . $tag . '>' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_template_single_title' ) ) {
|
||||
/**
|
||||
* Function for overriding product title template in Single Product template
|
||||
*/
|
||||
function calla_elated_woocommerce_template_single_title() {
|
||||
$tag = calla_elated_options()->getOptionValue( 'eltdf_single_product_title_tag' );
|
||||
if ( $tag === '' ) {
|
||||
$tag = 'h1';
|
||||
}
|
||||
|
||||
the_title( '<' . $tag . ' itemprop="name" class="eltdf-single-product-title">', '</' . $tag . '>' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_sale_flash' ) ) {
|
||||
/**
|
||||
* Function for overriding Sale Flash Template
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function calla_elated_woocommerce_sale_flash() {
|
||||
return '<span class="eltdf-onsale">' . esc_html__( 'Sale', 'calla' ) . '</span>';
|
||||
}
|
||||
|
||||
add_filter( 'woocommerce_sale_flash', 'calla_elated_woocommerce_sale_flash' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_product_out_of_stock' ) ) {
|
||||
/**
|
||||
* Function for adding Out Of Stock Template
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function calla_elated_woocommerce_product_out_of_stock() {
|
||||
global $product;
|
||||
|
||||
if ( ! $product->is_in_stock() ) {
|
||||
print '<span class="eltdf-out-of-stock">' . esc_html__( 'Sold', 'calla' ) . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'woocommerce_product_thumbnails', 'calla_elated_woocommerce_product_out_of_stock', 20 );
|
||||
add_action( 'woocommerce_before_shop_loop_item_title', 'calla_elated_woocommerce_product_out_of_stock', 10 );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_new_flash' ) ) {
|
||||
/**
|
||||
* Function for adding new flash template
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function calla_elated_woocommerce_new_flash() {
|
||||
$new = get_post_meta( get_the_ID(), 'eltdf_show_new_sign_woo_meta', true );
|
||||
|
||||
if ( $new === 'yes' ) {
|
||||
print '<span class="eltdf-new-product">' . esc_html__( 'New', 'calla' ) . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'woocommerce_product_thumbnails', 'calla_elated_woocommerce_new_flash', 21 );
|
||||
add_action( 'woocommerce_before_shop_loop_item_title', 'calla_elated_woocommerce_new_flash', 11 );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_view_all_pagination' ) ) {
|
||||
/**
|
||||
* Function for adding New WooCommerce Pagination Template
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function calla_elated_woocommerce_view_all_pagination() {
|
||||
global $wp_query;
|
||||
|
||||
if ( $wp_query->max_num_pages <= 1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$html = '';
|
||||
$shop_id = calla_elated_get_woo_shop_page_id();
|
||||
|
||||
if ( ! empty( $shop_id ) && $shop_id !== -1 ) {
|
||||
$html .= '<div class="eltdf-woo-view-all-pagination">';
|
||||
$html .= '<a href="' . get_permalink( $shop_id ) . '?woo-products-count=view-all">' . esc_html__( 'View All', 'calla' ) . '</a>';
|
||||
$html .= '</div>';
|
||||
}
|
||||
|
||||
echo wp_kses_post( $html );
|
||||
}
|
||||
|
||||
//add_action('woocommerce_after_shop_loop', 'calla_elated_woocommerce_view_all_pagination', 11);
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woo_view_all_pagination_additional_tag_before' ) ) {
|
||||
function calla_elated_woo_view_all_pagination_additional_tag_before() {
|
||||
|
||||
print '<div class="eltdf-woo-pagination-holder"><div class="eltdf-woo-pagination-inner">';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woo_view_all_pagination_additional_tag_after' ) ) {
|
||||
function calla_elated_woo_view_all_pagination_additional_tag_after() {
|
||||
|
||||
print '</div></div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_single_product_content_additional_tag_before' ) ) {
|
||||
function calla_elated_single_product_content_additional_tag_before() {
|
||||
|
||||
print '<div class="eltdf-single-product-content">';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_single_product_content_additional_tag_after' ) ) {
|
||||
function calla_elated_single_product_content_additional_tag_after() {
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_single_product_summary_additional_tag_before' ) ) {
|
||||
function calla_elated_single_product_summary_additional_tag_before() {
|
||||
|
||||
print '<div class="eltdf-single-product-summary">';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_single_product_summary_additional_tag_after' ) ) {
|
||||
function calla_elated_single_product_summary_additional_tag_after() {
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_pl_holder_additional_tag_before' ) ) {
|
||||
function calla_elated_pl_holder_additional_tag_before() {
|
||||
|
||||
print '<div class="eltdf-pl-main-holder">';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_pl_holder_additional_tag_after' ) ) {
|
||||
function calla_elated_pl_holder_additional_tag_after() {
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_pl_inner_additional_tag_before' ) ) {
|
||||
function calla_elated_pl_inner_additional_tag_before() {
|
||||
|
||||
print '<div class="eltdf-pl-inner">';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_pl_inner_additional_tag_after' ) ) {
|
||||
function calla_elated_pl_inner_additional_tag_after() {
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_pl_image_additional_tag_before' ) ) {
|
||||
function calla_elated_pl_image_additional_tag_before() {
|
||||
|
||||
print '<div class="eltdf-pl-image">';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_pl_image_additional_tag_after' ) ) {
|
||||
function calla_elated_pl_image_additional_tag_after() {
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_pl_inner_text_additional_tag_before' ) ) {
|
||||
function calla_elated_pl_inner_text_additional_tag_before() {
|
||||
$info_position = calla_elated_options()->getOptionValue('eltdf_woo_product_list_info_position');
|
||||
/*Change to true to have different btn behavior*/
|
||||
$btn_from_bottom = false;
|
||||
$btn_position_class = '';
|
||||
|
||||
if ( $info_position === 'info_below_image' && $btn_from_bottom) {
|
||||
$btn_position_class = 'eltdf-pl-button-from-bottom';
|
||||
} else {
|
||||
$btn_position_class = 'eltdf-pl-hover-overlay';
|
||||
}
|
||||
|
||||
print '<div class="eltdf-pl-text '.esc_attr($btn_position_class).'"><div class="eltdf-pl-text-outer"><div class="eltdf-pl-text-inner">';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_pl_inner_text_additional_tag_after' ) ) {
|
||||
function calla_elated_pl_inner_text_additional_tag_after() {
|
||||
|
||||
print '</div></div></div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_pl_text_wrapper_additional_tag_before' ) ) {
|
||||
function calla_elated_pl_text_wrapper_additional_tag_before() {
|
||||
|
||||
print '<div class="eltdf-pl-text-wrapper">';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_pl_text_wrapper_additional_tag_after' ) ) {
|
||||
function calla_elated_pl_text_wrapper_additional_tag_after() {
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_pl_rating_additional_tag_before' ) ) {
|
||||
function calla_elated_pl_rating_additional_tag_before() {
|
||||
global $product;
|
||||
|
||||
if ( get_option( 'woocommerce_enable_review_rating' ) !== 'no' ) {
|
||||
$rating_html = wc_get_rating_html( $product->get_average_rating() );
|
||||
|
||||
if ( $rating_html !== '' ) {
|
||||
print '<div class="eltdf-pl-rating-holder">';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_pl_rating_additional_tag_after' ) ) {
|
||||
function calla_elated_pl_rating_additional_tag_after() {
|
||||
global $product;
|
||||
|
||||
if ( get_option( 'woocommerce_enable_review_rating' ) !== 'no' ) {
|
||||
$rating_html = wc_get_rating_html( $product->get_average_rating() );
|
||||
|
||||
if ( $rating_html !== '' ) {
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_share' ) ) {
|
||||
/**
|
||||
* Function that social share for product page
|
||||
* Return array array of WooCommerce pages
|
||||
*/
|
||||
function calla_elated_woocommerce_share() {
|
||||
return '';
|
||||
if ( calla_elated_core_plugin_installed() && calla_elated_options()->getOptionValue( 'enable_social_share' ) == 'yes' && calla_elated_options()->getOptionValue( 'enable_social_share_on_product' ) == 'yes' ) :
|
||||
print '<div class="eltdf-woo-social-share-holder">';
|
||||
print '<span>' . esc_html__( 'Share:', 'calla' ) . '</span>';
|
||||
echo calla_elated_get_social_share_html();
|
||||
print '</div>';
|
||||
endif;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_woocommerce_single_product_title' ) ) {
|
||||
/**
|
||||
* Function that checks option for single product title and overrides it with filter
|
||||
*/
|
||||
function calla_elated_woocommerce_single_product_title( $show_title_area ) {
|
||||
if ( is_singular( 'product' ) ) {
|
||||
$woo_title_meta = get_post_meta( get_the_ID(), 'eltdf_show_title_area_woo_meta', true );
|
||||
|
||||
if ( empty( $woo_title_meta ) ) {
|
||||
$woo_title_main = calla_elated_options()->getOptionValue( 'show_title_area_woo' );
|
||||
|
||||
if ( ! empty( $woo_title_main ) ) {
|
||||
$show_title_area = $woo_title_main == 'yes' ? true : false;
|
||||
}
|
||||
} else {
|
||||
$show_title_area = $woo_title_meta == 'yes' ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
return $show_title_area;
|
||||
}
|
||||
|
||||
add_filter( 'calla_elated_show_title_area', 'calla_elated_woocommerce_single_product_title' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_set_title_text_output_for_woocommerce' ) ) {
|
||||
function calla_elated_set_title_text_output_for_woocommerce( $title ) {
|
||||
|
||||
if ( is_product_category() || is_product_tag() ) {
|
||||
global $wp_query;
|
||||
|
||||
$tax = $wp_query->get_queried_object();
|
||||
$category_title = $tax->name;
|
||||
$title = $category_title;
|
||||
} elseif ( calla_elated_is_woocommerce_shop() || is_singular( 'product' ) ) {
|
||||
$shop_id = calla_elated_get_woo_shop_page_id();
|
||||
$title = $shop_id !== -1 ? get_the_title( $shop_id ) : esc_html__( 'Shop', 'calla' );
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
add_filter( 'calla_elated_title_text', 'calla_elated_set_title_text_output_for_woocommerce' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_set_breadcrumbs_output_for_woocommerce' ) ) {
|
||||
function calla_elated_set_breadcrumbs_output_for_woocommerce( $childContent, $delimiter, $before, $after ) {
|
||||
$shop_id = calla_elated_get_woo_shop_page_id();
|
||||
|
||||
if ( calla_elated_is_product_category() ) {
|
||||
$childContent = '';
|
||||
|
||||
if ( ! empty( $shop_id ) && $shop_id !== -1 ) {
|
||||
$childContent .= '<a itemprop="url" href="' . get_permalink( $shop_id ) . '">' . get_the_title( $shop_id ) . '</a>' . $delimiter;
|
||||
}
|
||||
|
||||
$thisCat = get_category( get_query_var( 'cat' ), false );
|
||||
if ( isset( $thisCat->parent ) && $thisCat->parent != 0 ) {
|
||||
$childContent .= get_category_parents( $thisCat->parent, true, ' ' . $delimiter );
|
||||
}
|
||||
|
||||
$childContent .= $before . single_cat_title( '', false ) . $after;
|
||||
|
||||
} elseif ( is_singular( 'product' ) ) {
|
||||
$childContent = '';
|
||||
$product = wc_get_product( get_the_ID() );
|
||||
$categories = ! empty( $product ) ? wc_get_product_category_list( $product->get_id(), ', ' ) : '';
|
||||
|
||||
if ( ! empty( $shop_id ) && $shop_id !== -1 ) {
|
||||
$childContent .= '<a itemprop="url" href="' . get_permalink( $shop_id ) . '">' . get_the_title( $shop_id ) . '</a>' . $delimiter;
|
||||
}
|
||||
|
||||
if ( ! empty( $categories ) ) {
|
||||
$childContent .= $categories . $delimiter;
|
||||
}
|
||||
|
||||
$childContent .= $before . get_the_title() . $after;
|
||||
|
||||
} elseif ( calla_elated_is_woocommerce_shop() ) {
|
||||
$childContent = $before . get_the_title( $shop_id ) . $after;
|
||||
}
|
||||
|
||||
return $childContent;
|
||||
}
|
||||
|
||||
add_filter( 'calla_elated_breadcrumbs_title_child_output', 'calla_elated_set_breadcrumbs_output_for_woocommerce', 10, 4 );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_set_sidebar_layout_for_woocommerce' ) ) {
|
||||
function calla_elated_set_sidebar_layout_for_woocommerce( $sidebar_layout ) {
|
||||
|
||||
if ( is_archive() && ( is_product_category() || is_product_tag() ) ) {
|
||||
$sidebar_layout = calla_elated_get_meta_field_intersect( 'sidebar_layout', calla_elated_get_woo_shop_page_id() );
|
||||
}
|
||||
|
||||
return $sidebar_layout;
|
||||
}
|
||||
|
||||
add_filter( 'calla_elated_sidebar_layout', 'calla_elated_set_sidebar_layout_for_woocommerce' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'calla_elated_set_sidebar_name_for_woocommerce' ) ) {
|
||||
function calla_elated_set_sidebar_name_for_woocommerce( $sidebar_name ) {
|
||||
|
||||
if ( is_archive() && ( is_product_category() || is_product_tag() ) ) {
|
||||
$sidebar_name = calla_elated_get_meta_field_intersect( 'custom_sidebar_area', calla_elated_get_woo_shop_page_id() );
|
||||
}
|
||||
|
||||
return $sidebar_name;
|
||||
}
|
||||
|
||||
add_filter( 'calla_elated_sidebar_name', 'calla_elated_set_sidebar_name_for_woocommerce' );
|
||||
}
|
||||
|
||||
if ( ! function_exists('calla_elated_loop_add_to_cart')) {
|
||||
|
||||
function calla_elated_loop_add_to_cart( $html, $product ){
|
||||
|
||||
if ( $product ) {
|
||||
$args = array();
|
||||
$defaults = array(
|
||||
'quantity' => 1,
|
||||
'class' => implode( ' ', array_filter( array(
|
||||
'button',
|
||||
'product_type_' . $product->get_type(),
|
||||
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
|
||||
$product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '',
|
||||
) ) ),
|
||||
);
|
||||
|
||||
$args = apply_filters( 'woocommerce_loop_add_to_cart_args', wp_parse_args( $args, $defaults ), $product );
|
||||
|
||||
$quantity = isset( $args['quantity'] ) ? $args['quantity'] : 1;
|
||||
$class = isset( $args['class'] ) ? $args['class'] : 'button';
|
||||
$class .= ' eltdf-pl-btn eltdf-btn-outline eltdf-btn-double-border eltdf-btn-small';
|
||||
|
||||
$html = '<a rel="nofollow" href="'.esc_url( $product->add_to_cart_url() ).'" data-quantity="'.esc_attr( $quantity ).'" data-product_id="'.esc_attr( $product->get_id() ).'" data-product_sku="'.esc_attr( $product->get_sku() ).'" class="'.$class.'">';
|
||||
$html .= '<span class="eltdf-btn-border eltdf-btn-border-first"></span><span class="eltdf-btn-border eltdf-btn-border-second"></span>';
|
||||
$html .= esc_html( $product->add_to_cart_text() );
|
||||
$html .= '</a>';
|
||||
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
add_filter('woocommerce_loop_add_to_cart_link','calla_elated_loop_add_to_cart', 10, 2);
|
||||
}
|
||||
Reference in New Issue
Block a user