first commit

This commit is contained in:
2025-02-24 22:33:42 +01:00
commit 737c037e85
18358 changed files with 5392983 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Layout 2
*
*/
if ($default_multiple_kb) {
if(!empty($settings['selected_knowledge_base'])){
$button_link = str_replace('%knowledge_base%', $settings['selected_knowledge_base'], get_term_link($term->slug, 'doc_category'));
}else{
$button_link = str_replace('%knowledge_base%', 'non-knowledgebase', get_term_link($term->slug, 'doc_category'));
}
} else {
$button_link = get_term_link($term->slug, 'doc_category');
}
echo '<a href="' . esc_url( $button_link ) . '" class="eael-better-docs-category-box-post layout__2">';
echo '<div class="eael-bd-cb-inner">';
if ($settings['show_icon']) {
$cat_icon_id = get_term_meta($term->term_id, 'doc_category_image-id', true);
if ($cat_icon_id) {
$cat_icon = wp_get_attachment_image($cat_icon_id, 'thumbnail', ['alt' => esc_attr(get_post_meta($cat_icon_id, '_wp_attachment_image_alt', true))]);
} else {
$cat_icon = '<img src="' . EAEL_PLUGIN_URL . 'assets/front-end/img/betterdocs-cat-icon.svg" alt="betterdocs-category-box-icon">';
}
echo '<div class="eael-bd-cb-cat-icon__layout-2">' . $cat_icon . '</div>';
}
if ($settings['show_title']) {
echo '<' . Helper::eael_validate_html_tag($settings['title_tag']) . ' class="eael-bd-cb-cat-title__layout-2"><span>' . $term->name . '</span></' . Helper::eael_validate_html_tag($settings['title_tag']) . '>';
}
if ($settings['show_count']) {
printf('<div class="eael-bd-cb-cat-count__layout-2"><span class="count-inner__layout-2">%s</span></div>', Helper::get_doc_post_count($term->count, $term->term_id));
}
echo '</div>';
echo '</a>';

View File

@@ -0,0 +1,43 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Default
*
*/
if ($default_multiple_kb) {
if(!empty($settings['selected_knowledge_base'])){
$button_link = str_replace('%knowledge_base%', $settings['selected_knowledge_base'], get_term_link($term->slug, 'doc_category'));
}else{
$button_link = str_replace('%knowledge_base%', 'non-knowledgebase', get_term_link($term->slug, 'doc_category'));
}
} else {
$button_link = get_term_link($term->slug, 'doc_category');
}
echo '<a href="' . esc_url( $button_link ) . '" class="eael-better-docs-category-box-post">
<div class="eael-bd-cb-inner">';
if ($settings['show_icon']) {
$cat_icon_id = get_term_meta($term->term_id, 'doc_category_image-id', true);
if ($cat_icon_id) {
$cat_icon = wp_get_attachment_image($cat_icon_id, 'thumbnail', ['alt' => esc_attr(get_post_meta($cat_icon_id, '_wp_attachment_image_alt', true))]);
} else {
$cat_icon = '<img src="' . EAEL_PLUGIN_URL . 'assets/front-end/img/betterdocs-cat-icon.svg" alt="betterdocs-category-box-icon">';
}
echo '<div class="eael-bd-cb-cat-icon">' . $cat_icon . '</div>';
}
if ($settings['show_title']) {
echo '<' . Helper::eael_validate_html_tag($settings['title_tag'] ). ' class="eael-bd-cb-cat-title">' . $term->name . '</' . Helper::eael_validate_html_tag($settings['title_tag']) . '>';
}
if ($settings['show_count']) {
printf('<div class="eael-bd-cb-cat-count"><span class="count-prefix">%s</span>%s<span class="count-suffix">%s</span></div>', Helper::eael_wp_kses($settings['count_prefix']) , Helper::get_doc_post_count($term->count, $term->term_id), Helper::eael_wp_kses($settings['count_suffix']));
}
echo '</div>
</a>';

View File

@@ -0,0 +1,170 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Layout 2
*
*/
echo '<article class="eael-better-docs-category-grid-post layout-2" data-id="' . get_the_ID() . '">
<div class="eael-bd-cg-inner">';
if ($settings['show_header'] === 'true') {
echo '<div class="eael-bd-cg-header">';
if ($settings['show_count']) {
echo '<div class="eael-docs-item-count" data-content="' . Helper::get_doc_post_count($term->count, $term->term_id) . '"></div>';
}
if ($settings['show_title']) {
echo '<' . Helper::eael_validate_html_tag($settings['title_tag']) . ' class="eael-docs-cat-title">' . $term->name . '</' . Helper::eael_validate_html_tag($settings['title_tag']) . '>';
}
echo '</div>';
}
if ($settings['show_list'] === 'true') {
echo '<div class="eael-bd-cg-body">';
$args = array(
'post_type' => 'docs',
'post_status' => 'publish',
'posts_per_page' => $settings['post_per_page'],
'orderby' => $settings['post_orderby'],
'order' => $settings['post_order'],
'tax_query' => array(
array(
'taxonomy' => 'doc_category',
'field' => 'slug',
'terms' => $term->slug,
'operator' => 'AND',
'include_children' => false,
),
),
);
$query = new \WP_Query($args);
if ($query->have_posts()) {
echo '<ul>';
while ($query->have_posts()) {
$query->the_post();
$attr = ['href="' . get_the_permalink() . '"'];
echo '<li>';
if (isset($settings['list_icon']['value']['url']) && !empty($settings['list_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-post-list-icon" src="' . esc_url( $settings['list_icon']['value']['url'] ). '" />';
} else {
echo '<i class="' . esc_attr( $settings['list_icon']['value'] ) . ' eael-bd-cg-post-list-icon"></i>';
}
echo '<a ' . implode(' ', $attr) . '>' . get_the_title() . '</a>
</li>';
}
echo '</ul>';
}
wp_reset_query();
// Nested category query
if ($settings['nested_subcategory'] === 'true') {
$args = array(
'child_of' => $term->term_id,
'order' => $settings['order'],
'orderby' => $settings['orderby'],
);
$sub_categories = get_terms('doc_category', $args);
if ($sub_categories) {
foreach ($sub_categories as $sub_category) {
echo '<span class="eael-bd-grid-sub-cat-title">';
if (isset($settings['nested_list_title_closed_icon']['value']['url']) && !empty($settings['nested_list_title_closed_icon']['value']['url'])) {
echo '<img class="toggle-arrow arrow-right" src="' . esc_url( $settings['nested_list_title_closed_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['nested_list_title_closed_icon']['value'] ) . ' toggle-arrow arrow-right"></i>';
}
if (isset($settings['nested_list_title_open_icon']['value']['url']) && !empty($settings['nested_list_title_open_icon']['value']['url'])) {
echo '<img class="toggle-arrow arrow-down" src="' . esc_url( $settings['nested_list_title_open_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['nested_list_title_open_icon']['value'] ) . ' toggle-arrow arrow-down"></i>';
}
echo '<a href="#">' . $sub_category->name . '</a></span>';
echo '<ul class="docs-sub-cat-list">';
$sub_args = array(
'post_type' => 'docs',
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'doc_category',
'field' => 'slug',
'terms' => $sub_category->slug,
'operator' => 'AND',
'include_children' => false,
),
),
);
$sub_args['posts_per_page'] = -1;
$sub_post_query = new \WP_Query($sub_args);
if ($sub_post_query->have_posts()):
while ($sub_post_query->have_posts()): $sub_post_query->the_post();
$sub_attr = ['href="' . get_the_permalink() . '"'];
echo '<li class="sub-list">';
if (isset($settings['list_icon']['value']['url']) && !empty($settings['list_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-post-list-icon" src="' . esc_url( $settings['list_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['list_icon']['value'] ) . ' eael-bd-cg-post-list-icon"></i>';
}
echo '<a ' . implode(' ', $sub_attr) . '>' . get_the_title() . '</a></li>';
endwhile;
endif;
wp_reset_query();
echo '</ul>';
}
}
}
echo '</div>';
}
echo '<div class="eael-bd-cg-footer">';
if ($settings['show_button']) {
if ($default_multiple_kb) {
if(!empty($settings['selected_knowledge_base'])){
if(!empty($settings['selected_knowledge_base'])){
$button_link = str_replace('%knowledge_base%', $settings['selected_knowledge_base'], get_term_link($term->slug, 'doc_category'));
}else{
$button_link = str_replace('%knowledge_base%', 'non-knowledgebase', get_term_link($term->slug, 'doc_category'));
}
}else{
$button_link = str_replace('%knowledge_base%', 'non-knowledgebase', get_term_link($term->slug, 'doc_category'));
}
} else {
$button_link = get_term_link($term->slug, 'doc_category');
}
echo '<a class="eael-bd-cg-button" href="' . esc_url( $button_link ) . '">';
if ($settings['icon_position'] === 'before') {
if (isset($settings['button_icon']['value']['url']) && !empty($settings['button_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-button-icon eael-bd-cg-button-icon-left" src="' . esc_url( $settings['button_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['button_icon']['value'] ) . ' eael-bd-cg-button-icon eael-bd-cg-button-icon-left"></i>';
}
}
echo Helper::eael_wp_kses($settings['button_text']);
if ($settings['icon_position'] === 'after') {
if (isset($settings['button_icon']['value']['url']) && !empty($settings['button_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-button-icon eael-bd-cg-button-icon-right" src="' . esc_url( $settings['button_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['button_icon']['value'] ) . ' eael-bd-cg-button-icon eael-bd-cg-button-icon-right"></i>';
}
}
echo '</a>';
}
echo '</div>
</div>
</article>';

View File

@@ -0,0 +1,223 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Default
*
*/
echo '<article class="eael-better-docs-category-grid-post" data-id="' . get_the_ID() . '">
<div class="eael-bd-cg-inner">';
if ($settings['show_header'] === 'true') {
echo '<div class="eael-bd-cg-header">
<div class="eael-bd-cg-header-inner">';
if ($settings['show_icon']) {
$cat_icon_id = get_term_meta($term->term_id, 'doc_category_image-id', true);
if ($cat_icon_id) {
$cat_icon = wp_get_attachment_image($cat_icon_id, 'thumbnail', ['alt' => esc_attr(get_post_meta($cat_icon_id, '_wp_attachment_image_alt', true))]);
} else {
$cat_icon = '<img src="' . EAEL_PLUGIN_URL . 'assets/front-end/img/betterdocs-cat-icon.svg" alt="betterdocs-category-grid-icon">';
}
echo '<div class="eael-docs-cat-icon">' . $cat_icon . '</div>';
}
if ($settings['show_title']) {
echo '<' . Helper::eael_validate_html_tag($settings['title_tag']) . ' class="eael-docs-cat-title">' . $term->name . '</' . Helper::eael_validate_html_tag($settings['title_tag']) . '>';
}
if ($settings['show_count']) {
echo '<div class="eael-docs-item-count">' . Helper::get_doc_post_count($term->count, $term->term_id) . '</div>';
}
echo '</div>
</div>';
}
if ($settings['show_list'] === 'true') {
echo '<div class="eael-bd-cg-body">';
$multiple_kb = Helper::get_betterdocs_multiple_kb_status();
if ($multiple_kb == true) {
$taxes = array('knowledge_base', 'doc_category');
foreach ($taxes as $tax) {
$kterms = get_terms($tax);
if (!is_wp_error($kterms)) {
foreach ($kterms as $kterm) {
$tax_map[$tax][$kterm->slug] = $kterm->term_taxonomy_id;
}
}
}
$args = array(
'post_type' => 'docs',
'post_status' => 'publish',
'posts_per_page' => $settings['post_per_page'],
'orderby' => $settings['post_orderby'],
'order' => $settings['post_order'],
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'doc_category',
'field' => 'term_taxonomy_id',
'operator' => 'IN',
'terms' => array($tax_map['doc_category'][$term->slug]),
'include_children' => false,
),
),
);
if(!empty($settings['selected_knowledge_base'])){
$args['tax_query'][] = array(
'taxonomy' => 'knowledge_base',
'field' => 'term_taxonomy_id',
'terms' => array($tax_map['knowledge_base'][$settings['selected_knowledge_base']]),
'operator' => 'IN',
'include_children' => false,
);
}
} else {
$args = array(
'post_type' => 'docs',
'post_status' => 'publish',
'posts_per_page' => $settings['post_per_page'],
'orderby' => $settings['post_orderby'],
'order' => $settings['post_order'],
'tax_query' => array(
array(
'taxonomy' => 'doc_category',
'field' => 'slug',
'terms' => $term->slug,
'operator' => 'AND',
'include_children' => false,
),
),
);
}
$query = new \WP_Query($args);
if ($query->have_posts()) {
echo '<ul>';
while ($query->have_posts()) {
$query->the_post();
$attr = ['href="' . get_the_permalink() . '"'];
echo '<li>';
if (isset($settings['list_icon']['value']['url']) && !empty($settings['list_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-post-list-icon" src="' . esc_url( $settings['list_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['list_icon']['value'] ) . ' eael-bd-cg-post-list-icon"></i>';
}
echo '<a ' . implode(' ', $attr) . '>' . get_the_title() . '</a>
</li>';
}
echo '</ul>';
}
wp_reset_query();
// Nested category query
if ($settings['nested_subcategory'] === 'true') {
$args = array(
'child_of' => $term->term_id,
'order' => $settings['order'],
'orderby' => $settings['orderby'],
);
$sub_categories = get_terms('doc_category', $args);
if ($sub_categories) {
foreach ($sub_categories as $sub_category) {
echo '<span class="eael-bd-grid-sub-cat-title">';
if (isset($settings['nested_list_title_closed_icon']['value']['url']) && !empty($settings['nested_list_title_closed_icon']['value']['url'])) {
echo '<img class="toggle-arrow arrow-right" src="' . esc_url( $settings['nested_list_title_closed_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['nested_list_title_closed_icon']['value'] ) . ' toggle-arrow arrow-right"></i>';
}
if (isset($settings['nested_list_title_open_icon']['value']['url']) && !empty($settings['nested_list_title_open_icon']['value']['url'])) {
echo '<img class="toggle-arrow arrow-down" src="' . esc_url( $settings['nested_list_title_open_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['nested_list_title_open_icon']['value'] ) . ' toggle-arrow arrow-down"></i>';
}
echo '<a href="#">' . $sub_category->name . '</a></span>';
echo '<ul class="docs-sub-cat-list">';
$sub_args = array(
'post_type' => 'docs',
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'doc_category',
'field' => 'slug',
'terms' => $sub_category->slug,
'operator' => 'AND',
'include_children' => false,
),
),
);
$sub_args['posts_per_page'] = -1;
$sub_post_query = new \WP_Query($sub_args);
if ($sub_post_query->have_posts()):
while ($sub_post_query->have_posts()): $sub_post_query->the_post();
$sub_attr = ['href="' . get_the_permalink() . '"'];
echo '<li class="sub-list">';
if (isset($settings['list_icon']['value']['url']) && !empty($settings['list_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-post-list-icon" src="' . esc_url( $settings['list_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['list_icon']['value'] ) . ' eael-bd-cg-post-list-icon"></i>';
}
echo '<a ' . implode(' ', $sub_attr) . '>' . get_the_title() . '</a></li>';
endwhile;
endif;
wp_reset_query();
echo '</ul>';
}
}
}
echo '</div>';
}
echo '<div class="eael-bd-cg-footer">';
if ($settings['show_button']) {
if ($default_multiple_kb) {
if(!empty($settings['selected_knowledge_base'])){
$button_link = str_replace('%knowledge_base%', $settings['selected_knowledge_base'], get_term_link($term->slug, 'doc_category'));
}else{
$button_link = str_replace('%knowledge_base%', 'non-knowledgebase', get_term_link($term->slug, 'doc_category'));
}
} else {
$button_link = get_term_link($term->slug, 'doc_category');
}
echo '<a class="eael-bd-cg-button" href="' . esc_url( $button_link ) . '">';
if ($settings['icon_position'] === 'before') {
if (isset($settings['button_icon']['value']['url']) && !empty($settings['button_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-button-icon eael-bd-cg-button-icon-left" src="' . esc_url( $settings['button_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['button_icon']['value'] ) . ' eael-bd-cg-button-icon eael-bd-cg-button-icon-left"></i>';
}
}
echo Helper::eael_wp_kses($settings['button_text']);
if ($settings['icon_position'] === 'after') {
if (isset($settings['button_icon']['value']['url']) && !empty($settings['button_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-button-icon eael-bd-cg-button-icon-right" src="' . esc_url( $settings['button_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['button_icon']['value'] ) . ' eael-bd-cg-button-icon eael-bd-cg-button-icon-right"></i>';
}
}
echo '</a>';
}
echo '</div>';
echo '</div>';
echo '</article>';

View File

@@ -0,0 +1,41 @@
<?php
/**
* Template Name: Default
*/
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
if (isset($content) && isset($link)) {
echo '<div class="swiper-slide">
<div class="ticker-content">';
if (!empty($link['url'])) {
echo '<a href="' . esc_url( $link['url'] ) . '" ';
if ($link['is_external'] == 'on') {
echo 'target="_blank" ';
}
if ($link['nofollow'] == 'on') {
echo 'rel="nofollow"';
}
echo '>';
}
echo $content;
if (!empty($link['url'])) {
echo '</a>';
}
echo '</div>
</div>';
} else {
echo '<div class="swiper-slide">
<div class="ticker-content">
<a href="' . get_the_permalink() . '" class="ticker-content-link">' . get_the_title() . '</a>
</div>
</div>';
}

View File

@@ -0,0 +1,91 @@
<?php
namespace Essential_Addons_Elementor\Template\Content;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
trait Product_Grid {
public static function render_template_( $args, $settings ) {
$query = new \WP_Query( $args );
ob_start();
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$product = wc_get_product( get_the_ID() );
if ( $settings['eael_product_grid_style_preset'] == 'eael-product-simple' || $settings['eael_product_grid_style_preset'] == 'eael-product-reveal' ) { ?>
<li class="product">
<a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">
<?php echo wp_kses_post( $product->get_image( 'woocommerce_thumbnail' )); ?>
<h2 class="woocommerce-loop-product__title"> <?php echo esc_html( $product->get_title()); ?> </h2>
<?php
if ( $settings['eael_product_grid_rating'] == 'yes' ) {
echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ));
}
if ( ! $product->managing_stock() && ! $product->is_in_stock() ) {
printf( '<span class="outofstock-badge">%s</span>', __( 'Stock <br/> Out', 'essential-addons-for-elementor-lite' ) );
} elseif ( $product->is_on_sale() ) {
printf( '<span class="onsale">%s</span>', __( 'Sale!', 'essential-addons-for-elementor-lite' ) );
}
?>
<span class="price"><?php echo wp_kses_post( $product->get_price_html()); ?></span>
</a>
<?php
woocommerce_template_loop_add_to_cart();
if ( isset( $settings['show_compare']) && 'yes' === $settings['show_compare'] ) {
self::print_compare_button( $product->get_id() );
}
?>
</li>
<?php
} else if ( $settings['eael_product_grid_style_preset'] == 'eael-product-overlay' ) {
?>
<li class="product">
<div class="overlay">
<?php echo $product->get_image( 'woocommerce_thumbnail' ); ?>
<div class="button-wrap clearfix">
<a href="<?php echo esc_url( $product->get_permalink()); ?>" class="product-link"><span class="fas fa-link"></span></a>
<?php
woocommerce_template_loop_add_to_cart();
if ( isset( $settings['show_compare']) && 'yes' === $settings['show_compare'] ) {
self::print_compare_button( $product->get_id(), 'icon' );
}
?>
</div>
</div>
<h2 class="woocommerce-loop-product__title"><?php echo esc_html( $product->get_title()); ?></h2>
<?php
if ($settings['eael_product_grid_rating'] === 'yes') {
echo wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() );
}
if ($product->is_on_sale()){
printf( '<span class="onsale">%s</span>', __( 'Sale!', 'essential-addons-for-elementor-lite' ));
}
?>
<span class="price"> <?php echo $product->get_price_html(); ?> </span>
</li>
<?php
} else {
if ( isset( $settings['show_compare']) && 'yes' === $settings['show_compare'] ) {
add_action( 'woocommerce_after_shop_loop_item', function (){
global $product;
if (!$product) return;
self::print_compare_button( $product->get_id() );
});
}
wc_get_template_part( 'content', 'product' );
}
}
} else {
printf( '<p class="no-posts-found">%</p>', __( 'No products found!', 'essential-addons-for-elementor-lite' ) );
}
wp_reset_postdata();
?>
<?php
return ob_get_clean();
}
}

View File

@@ -0,0 +1,91 @@
<?php
namespace Essential_Addons_Elementor\Template\Content;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
trait Woo_Product_List {
public static function render_template_( $args, $settings ) {
$query = new \WP_Query( $args );
ob_start();
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$product = wc_get_product( get_the_ID() );
if ( $settings['eael_woo_product_list_style_preset'] == 'eael-product-simple' || $settings['eael_woo_product_list_style_preset'] == 'eael-product-reveal' ) { ?>
<li class="product">
<a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">
<?php echo wp_kses_post( $product->get_image( 'woocommerce_thumbnail' )); ?>
<h2 class="woocommerce-loop-product__title"> <?php echo esc_html( $product->get_title()); ?> </h2>
<?php
if ( $settings['eael_woo_product_list_rating'] == 'yes' ) {
echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ));
}
if ( ! $product->managing_stock() && ! $product->is_in_stock() ) {
printf( '<span class="outofstock-badge">%s</span>', __( 'Stock <br/> Out', 'essential-addons-for-elementor-lite' ) );
} elseif ( $product->is_on_sale() ) {
printf( '<span class="onsale">%s</span>', __( 'Sale!', 'essential-addons-for-elementor-lite' ) );
}
?>
<span class="price"><?php echo wp_kses_post( $product->get_price_html()); ?></span>
</a>
<?php
woocommerce_template_loop_add_to_cart();
if ( isset( $settings['show_compare']) && 'yes' === $settings['show_compare'] ) {
self::print_compare_button( $product->get_id() );
}
?>
</li>
<?php
} else if ( $settings['eael_woo_product_list_style_preset'] == 'eael-product-overlay' ) {
?>
<li class="product">
<div class="overlay">
<?php echo $product->get_image( 'woocommerce_thumbnail' ); ?>
<div class="button-wrap clearfix">
<a href="<?php echo esc_url( $product->get_permalink()); ?>" class="product-link"><span class="fas fa-link"></span></a>
<?php
woocommerce_template_loop_add_to_cart();
if ( isset( $settings['show_compare']) && 'yes' === $settings['show_compare'] ) {
self::print_compare_button( $product->get_id(), 'icon' );
}
?>
</div>
</div>
<h2 class="woocommerce-loop-product__title"><?php echo esc_html( $product->get_title()); ?></h2>
<?php
if ($settings['eael_woo_product_list_rating'] === 'yes') {
echo wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() );
}
if ($product->is_on_sale()){
printf( '<span class="onsale">%s</span>', __( 'Sale!', 'essential-addons-for-elementor-lite' ));
}
?>
<span class="price"> <?php echo $product->get_price_html(); ?> </span>
</li>
<?php
} else {
if ( isset( $settings['show_compare']) && 'yes' === $settings['show_compare'] ) {
add_action( 'woocommerce_after_shop_loop_item', function (){
global $product;
if (!$product) return;
self::print_compare_button( $product->get_id() );
});
}
wc_get_template_part( 'content', 'product' );
}
}
} else {
printf( '<p class="no-posts-found">%</p>', __( 'No products found!', 'essential-addons-for-elementor-lite' ) );
}
wp_reset_postdata();
?>
<?php
return ob_get_clean();
}
}

View File

@@ -0,0 +1,627 @@
<?php
/**
* Template Name: Default
*/
use \Essential_Addons_Elementor\Classes\Helper;
use Essential_Addons_Elementor\Elements\Product_Grid;
use \Elementor\Group_Control_Image_Size;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
if ( has_post_thumbnail() ) {
$settings[ 'eael_image_size_customize' ] = [
'id' => get_post_thumbnail_id(),
];
$settings['eael_image_size_customize_size'] = $settings['eael_product_grid_image_size_size'];
$thumbnail_html = Group_Control_Image_Size::get_attachment_image_html( $settings,'eael_image_size_customize' );
}
$title_tag = isset( $settings['eael_product_grid_title_html_tag'] ) ? Helper::eael_validate_html_tag($settings['eael_product_grid_title_html_tag']) : 'h2';
$should_print_compare_btn = isset( $settings['show_compare'] ) && 'yes' === $settings['show_compare'];
if ( function_exists( 'YITH_WCWL' ) ) {
$should_print_wishlist_btn = isset( $settings['eael_product_grid_wishlist'] ) && 'yes' === $settings['eael_product_grid_wishlist'];
}
// Improvement
$grid_style_preset = isset($settings['eael_product_grid_style_preset']) ? $settings['eael_product_grid_style_preset'] : '';
$list_style_preset = isset($settings['eael_product_list_style_preset']) ? $settings['eael_product_list_style_preset'] : '';
$sale_badge_align = isset( $settings['eael_product_sale_badge_alignment'] ) ? esc_attr( $settings['eael_product_sale_badge_alignment'] ) : '';
$sale_badge_preset = isset( $settings['eael_product_sale_badge_preset'] ) ? esc_attr( $settings['eael_product_sale_badge_preset'] ) : '';
// should print vars
$should_print_rating = isset( $settings['eael_product_grid_rating'] ) && 'yes' === $settings['eael_product_grid_rating'];
$should_print_quick_view = isset( $settings['eael_product_grid_quick_view'] ) && 'yes' === $settings['eael_product_grid_quick_view'];
$should_print_image_clickable = isset( $settings['eael_product_grid_image_clickable'] ) && 'yes' === $settings['eael_product_grid_image_clickable'];
$should_print_price = isset( $settings['eael_product_grid_price'] ) && 'yes' === $settings['eael_product_grid_price'];
$should_print_excerpt = isset( $settings['eael_product_grid_excerpt'] ) && ('yes' === $settings['eael_product_grid_excerpt'] && has_excerpt());
$widget_id = isset($settings['eael_widget_id']) ? $settings['eael_widget_id'] : null;
$sale_badge_text = !empty($settings['eael_product_sale_text']) ? $settings['eael_product_sale_text'] : __( 'Sale!', 'essential-addons-for-elementor-lite' );
$stock_out_badge_text = !empty($settings['eael_product_stockout_text']) ?$settings['eael_product_stockout_text'] : __( 'Stock <br/> Out', 'essential-addons-for-elementor-lite' );
$is_show_badge = $settings['eael_show_product_sale_badge'];
$quick_view_setting = [
'widget_id' => $widget_id,
'product_id' => $product->get_id(),
'page_id' => $settings['eael_page_id'],
];
$product_wrapper_classes = implode( " ", apply_filters( 'eael_product_wrapper_class', [], $product->get_id(), 'eicon-woocommerce' ) );
if ( $grid_style_preset == 'eael-product-simple' || $grid_style_preset == 'eael-product-reveal' ) { ?>
<li class="product <?php echo esc_attr( $product_wrapper_classes ); ?>">
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_before_shop_loop_item' );
}
?>
<div class="eael-product-wrap">
<?php
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo wp_kses_post( $product->get_image( $settings['eael_product_grid_image_size_size'], [ 'loading' => 'eager', 'class'=> 'attachment-woocommerce_thumbnail size-woocommerce_thumbnail wvs-archive-product-image' ] ) );
if ( $should_print_image_clickable ) {
echo '</a>';
}
// printf('<%1$s class="woocommerce-loop-product__title"><a href="%3$s" class="woocommerce-LoopProduct-link woocommerce-loop-product__link woocommerce-loop-product__title_link woocommerce-loop-product__title_link_simple woocommerce-loop-product__title_link_reveal">%2$s</a></%1$s>', $title_tag, $product->get_title(), $product->get_permalink());
echo '<div class="eael-product-title">
<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s class="woocommerce-loop-product__title">%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>
</div>';
if ( $should_print_rating ) {
echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) );
}
if ( $is_show_badge ){
if ( ! $product->is_in_stock() ) {
printf( '<span class="outofstock-badge ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">%s</span>', $stock_out_badge_text );
} elseif ( $product->is_on_sale() ) {
printf( '<span class="onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">%s</span>', $sale_badge_text );
}
}
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
?>
<?php
woocommerce_template_loop_add_to_cart();
if ( $should_print_compare_btn ) {
Product_Grid::print_compare_button( $product->get_id() );
}
?>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<div class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</div>';
}
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</div>
</li>
<?php
} else if ( $grid_style_preset == 'eael-product-overlay' ) {
?>
<li <?php post_class( "product {$product_wrapper_classes}" ); ?>>
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_before_shop_loop_item' );
}
?>
<div class="overlay">
<?php
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo $product->get_image( $settings['eael_product_grid_image_size_size'], [ 'loading' => 'eager' ] );
if ( $should_print_image_clickable ) {
echo '</a>';
}
?>
<div class="button-wrap clearfix">
<a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="product-link"><span class="fas fa-link"></span></a>
<?php
woocommerce_template_loop_add_to_cart();
if ( $should_print_compare_btn ) {
Product_Grid::print_compare_button( $product->get_id(), 'icon' );
}
?>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<div class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</div>';
}
?>
</div>
</div>
<?php
// printf('<%1$s class="woocommerce-loop-product__title"><a href="%3$s" class="woocommerce-LoopProduct-link woocommerce-loop-product__link woocommerce-loop-product__title_link woocommerce-loop-product__title_link_overlay">%2$s</a></%1$s>', $title_tag, $product->get_title(), $product->get_permalink());
echo '<div class="eael-product-title">
<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s class="woocommerce-loop-product__title">%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>
</div>';
if ( $should_print_rating ) {
echo wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() );
}
if ( $is_show_badge ) {
if ( ! $product->is_in_stock() ) {
printf( '<span class="outofstock-badge ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">%s</span>', $stock_out_badge_text );
} elseif ( $product->is_on_sale() ) {
printf( '<span class="onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">%s</span>', $sale_badge_text );
}
}
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</li>
<?php
} else if (($grid_style_preset == 'eael-product-preset-5') || ($grid_style_preset == 'eael-product-preset-6') || ($grid_style_preset == 'eael-product-preset-7')) {
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li <?php post_class( "product {$product_wrapper_classes}" ); ?>>
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_before_shop_loop_item' );
}
?>
<div class="eael-product-wrap">
<div class="product-image-wrap">
<div class="image-wrap">
<?php
if ( $is_show_badge ) {
echo( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . $stock_out_badge_text . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . $sale_badge_text . '</span>' : '' ) );
}
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo wp_kses_post( $product->get_image( $settings['eael_product_grid_image_size_size'], [ 'loading' => 'eager' ] ) );
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
<div class="image-hover-wrap">
<?php if($grid_style_preset == 'eael-product-preset-5'){ ?>
<ul class="icons-wrap block-style">
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-grid-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<?php
if ( $should_print_compare_btn ) {
echo '<li class="add-to-compare">';
Product_Grid::print_compare_button( $product->get_id(), 'icon' );
echo '</li>';
}
?>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<li class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</li>';
}
?>
<li class="view-details"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
</ul>
<?php } elseif ($grid_style_preset == 'eael-product-preset-7') { ?>
<ul class="icons-wrap block-box-style">
<li class="add-to-cart"><?php
woocommerce_template_loop_add_to_cart(); ?></li>
<?php
if ( $should_print_compare_btn ) {
echo '<li class="add-to-compare">';
Product_Grid::print_compare_button( $product->get_id(), 'icon' );
echo '</li>';
}
?>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<li class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</li>';
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-grid-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<li class="view-details"><?php echo '<a href="' . $product->get_permalink
() . '"><i class="fas fa-link"></i></a>'; ?></li>
</ul>
<?php } else { ?>
<ul class="icons-wrap box-style">
<li class="add-to-cart"><?php
woocommerce_template_loop_add_to_cart();
?></li>
<?php
if ( $should_print_compare_btn ) {
echo '<li class="add-to-compare">';
Product_Grid::print_compare_button( $product->get_id(), 'icon' );
echo '</li>';
}
?>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<li class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</li>';
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-grid-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<li class="view-details" title="Details"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
</ul>
<?php }
?>
</div>
</div>
<div class="product-details-wrap">
<?php
if(($grid_style_preset == 'eael-product-preset-7') && $should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
?>
<div class="eael-product-title">
<?php
echo '<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>';
?>
<?php //printf('<%1$s><a href="%3$s" class="woocommerce-LoopProduct-link woocommerce-loop-product__link woocommerce-loop-product__title_link woocommerce-loop-product__title_link_simple woocommerce-loop-product__title_link_reveal">%2$s</a></%1$s>', $title_tag, $product->get_title(), $product->get_permalink()); ?>
</div>
<?php if(($grid_style_preset != 'eael-product-preset-7') && $should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}?>
</div>
</div>
<?php
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</li>
<?php
}
} else if ($grid_style_preset == 'eael-product-preset-8') {
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li <?php post_class( "product {$product_wrapper_classes}" ); ?>>
<div class="eael-product-wrap">
<div class="product-image-wrap">
<div class="image-wrap">
<?php
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
if ( $is_show_badge ) {
echo( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . $stock_out_badge_text . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . $sale_badge_text . '</span>' : '' ) );
}
echo $product->get_image($settings['eael_product_grid_image_size_size'], ['loading' => 'eager']);
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
<div class="image-hover-wrap">
<ul class="icons-wrap over-box-style">
<li class="add-to-cart"><?php
woocommerce_template_loop_add_to_cart(); ?>
</li>
<?php
if ( $should_print_compare_btn ) {
echo '<li class="add-to-compare">';
Product_Grid::print_compare_button( $product->get_id(), 'icon' );
echo '</li>';
}
?>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<li class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</li>';
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-grid-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
</ul>
</div>
</div>
<div class="product-details-wrap">
<?php
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
?>
<div class="eael-product-title">
<?php
echo '<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>';
?>
</div>
</div>
</div>
</li>
<?php
}
} else if(($list_style_preset == 'eael-product-list-preset-1') ||
($list_style_preset == 'eael-product-list-preset-2') ||
($list_style_preset == 'eael-product-list-preset-3') ||
($list_style_preset == 'eael-product-list-preset-4')) {
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li class="product <?php echo esc_attr( "{$product_wrapper_classes} {$list_style_preset}" ) ?>">
<div class="eael-product-wrap">
<div class="product-image-wrap">
<div class="image-wrap">
<?php
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
if ( $is_show_badge ) {
echo( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . $stock_out_badge_text . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . $sale_badge_text . '</span>' : '' ) );
}
echo wp_kses_post( $product->get_image( $settings['eael_product_grid_image_size_size'], [ 'loading' => 'eager' ] ) );
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
</div>
<div class="product-details-wrap">
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_before_shop_loop_item' );
}
if ($list_style_preset == 'eael-product-list-preset-2') {
echo '<div class="eael-product-title">
<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>
</div>';
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words(strip_shortcodes(get_the_excerpt()), $settings['eael_product_grid_excerpt_length'], $settings['eael_product_grid_excerpt_expanison_indicator']) . '</p>';
echo '</div>';
}
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
} elseif ($list_style_preset == 'eael-product-list-preset-3') {
echo '<div class="price-wrap">';
if ($should_print_price) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
echo '</div>
<div class="title-wrap">
<div class="eael-product-title">
<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>
</div>';
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words(strip_shortcodes(get_the_excerpt() ? get_the_excerpt() :
get_the_content()), $settings['eael_product_grid_excerpt_length'], $settings['eael_product_grid_excerpt_expanison_indicator']) . '</p>';
echo '</div>';
}
echo '</div>';
} elseif ($list_style_preset == 'eael-product-list-preset-4') {
if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
echo '<div class="eael-product-title">
<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>
</div>';
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words(strip_shortcodes(get_the_excerpt() ? get_the_excerpt() :
get_the_content()), $settings['eael_product_grid_excerpt_length'], $settings['eael_product_grid_excerpt_expanison_indicator']) . '</p>';
echo '</div>';
}
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
} else {
echo '<div class="eael-product-title">
<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>
</div>';
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words(strip_shortcodes(get_the_excerpt() ? get_the_excerpt() :
get_the_content()), $settings['eael_product_grid_excerpt_length'], $settings['eael_product_grid_excerpt_expanison_indicator']) . '</p>';
echo '</div>';
};
}
?>
<ul class="icons-wrap <?php echo esc_attr( $settings['eael_product_action_buttons_preset'] ); ?>">
<?php
if ( $should_print_compare_btn ) {
echo '<li class="add-to-compare">';
Product_Grid::print_compare_button( $product->get_id(), 'icon' );
echo '</li>';
}
?>
<li class="add-to-cart"><?php
woocommerce_template_loop_add_to_cart(); ?></li>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<li class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</li>';
}
?>
<?php
if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-grid-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
</ul>
<?php
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</div>
</div>
</li>
<?php
}
}else {
if($settings['eael_product_grid_rating']!='yes'){
remove_action('woocommerce_after_shop_loop_item_title','woocommerce_template_loop_rating',5);
}
add_action('woocommerce_before_shop_loop_item_title',function() use ( $stock_out_badge_text ){
global $product;
if ( ! $product->is_in_stock() ) {
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
echo '<span class="outofstock-badge">'. $stock_out_badge_text .'</span>';
}
},9);
add_filter('woocommerce_sale_flash', function($text, $post, $product) use( $sale_badge_text ) {
return '<span class="onsale" data-notification="default">'. $sale_badge_text .'</span>';
}, 10, 3);
if ( $should_print_compare_btn ) {
add_action( 'woocommerce_after_shop_loop_item', [
'\Essential_Addons_Elementor\Elements\Product_Grid',
'print_compare_button',
] );
}
$thumb_size = isset($settings['eael_product_grid_image_size_size']) ? $settings['eael_product_grid_image_size_size'] : '';
global $eael_thumb_default;
add_filter( 'single_product_archive_thumbnail_size', function($size)use($thumb_size){
global $eael_thumb_default;
$eael_thumb_default = $size;
return $thumb_size != '' ? $thumb_size : $size ;
});
wc_get_template_part( 'content', 'product' );
add_filter( 'single_product_archive_thumbnail_size', function($size){
global $eael_thumb_default;
return !empty($eael_thumb_default) ? $eael_thumb_default : $size;
});
if ( $should_print_compare_btn ) {
remove_action( 'woocommerce_after_shop_loop_item', [
'\Essential_Addons_Elementor\Elements\Product_Grid',
'print_compare_button',
] );
}
}

View File

@@ -0,0 +1,407 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
use \Elementor\Group_Control_Image_Size;
/**
* Template Name: Default
*/
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
$thumbnail_html = '';
if ( $settings['eael_show_image'] == 'yes' ) {
$settings[ 'eael_image_size_customize' ] = [
'id' => get_post_thumbnail_id(),
];
$settings['eael_image_size_customize_size'] = $settings['image_size'];
$thumbnail_html = Group_Control_Image_Size::get_attachment_image_html( $settings,'eael_image_size_customize' );
}
global $authordata;
$author_link = '';
if ( is_object( $authordata ) ) {
$author_name = $authordata->display_name;
if ( isset( $authordata->first_name ) ) {
$author_name = $authordata->first_name;
if ( isset( $authordata->last_name ) ) {
$author_name .= ' ' . $authordata->last_name;
}
}
$author_link = sprintf(
'<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ),
/* translators: %s: Author's display name. */
esc_attr( sprintf( __( 'Posts by %s' ), $author_name ) ),
$author_name
);
}
$enable_ratio = $settings['enable_postgrid_image_ratio'] == 'yes' ? 'eael-image-ratio':'';
$title_tag = isset($settings['title_tag']) ? Helper::eael_validate_html_tag($settings['title_tag']) : 'h2';
if ($settings['eael_post_grid_preset_style'] === 'two') {
echo '<article class="eael-grid-post eael-post-grid-column" data-id="' . get_the_ID() . '">
<div class="eael-grid-post-holder">
<div class="eael-grid-post-holder-inner">';
if ( $thumbnail_html && 'yes' === $settings['eael_show_image'] ) {
echo '<div class="eael-entry-media">';
if ( 'yes' === $settings['eael_show_post_terms'] && 'yes' === $settings['eael_post_terms_on_image_hover'] ) {
echo Helper::get_terms_as_list($settings['eael_post_terms'], $settings['eael_post_terms_max_length']);
}
echo '<div class="eael-entry-overlay ' . esc_attr( $settings['eael_post_grid_hover_animation'] ) . '">';
if (isset($settings['eael_post_grid_bg_hover_icon_new']['url'])) {
echo '<img src="' . esc_url($settings['eael_post_grid_bg_hover_icon_new']['url']) . '" alt="' . esc_attr(get_post_meta($settings['eael_post_grid_bg_hover_icon_new']['id'], '_wp_attachment_image_alt', true)) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['eael_post_grid_bg_hover_icon_new']['value'] ) . '" aria-hidden="true"></i>';
}
echo '<a href="' . get_the_permalink() . '"' . $link_settings['image_link_nofollow'] . '' . $link_settings['image_link_target_blank'] . '></a>';
echo '</div>';
echo '<div class="eael-entry-thumbnail '.$enable_ratio.'">
'.$thumbnail_html.'
</div>
</div>';
}
if ($settings['eael_show_title'] || $settings['eael_show_meta'] || $settings['eael_show_excerpt']) {
echo '<div class="eael-entry-wrapper">';
if ($settings['eael_show_title']) {
echo '<header class="eael-entry-header"><' . $title_tag . ' class="eael-entry-title">';
echo '<a
class="eael-grid-post-link"
href="' . get_the_permalink() . '"
title="' . strip_tags( get_the_title() ) . '"' . $link_settings['title_link_nofollow'] . '' . $link_settings['title_link_target_blank'] . '>';
if (empty($settings['eael_title_length'])) {
echo get_the_title();
} else {
echo implode(" ", array_slice(explode(" ", get_the_title()), 0, $settings['eael_title_length']));
}
echo '</a>';
echo '</' . $title_tag . '></header>';
}
if ($settings['meta_position'] == 'meta-entry-header') {
echo '<div class="eael-entry-header-after style-two">';
if ( isset( $settings['eael_show_avatar_two'] ) && 'yes' === $settings['eael_show_avatar_two'] ) {
echo '<div class="eael-author-avatar"><a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_avatar(get_the_author_meta('ID'), 96, '', get_the_author_meta( 'display_name' ) ) . '</a></div>';
}
if ($settings['eael_show_meta']) {
echo '<div class="eael-entry-meta">';
if ( isset( $settings['eael_show_author_two'] ) && 'yes' === $settings['eael_show_author_two'] ) {
echo '<span class="eael-posted-by">' . $author_link . '</span>';
}
if ($settings['eael_show_date'] === 'yes') {
echo '<span class="eael-posted-on eael-meta-posted-on"><i class="far fa-clock"></i><time datetime="' . get_the_date() . '">' . get_the_date() . '</time></span>';
}
echo '</div>';
}
echo '</div>';
}
if ($settings['eael_show_excerpt'] || $settings['eael_show_read_more_button']) {
echo '<div class="eael-entry-content">
<div class="eael-grid-post-excerpt">';
if ($settings['eael_show_excerpt']) {
if (empty($settings['eael_excerpt_length'])) {
echo '<p>' . strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()) . '</p>';
} else {
echo '<p>' . wp_trim_words( strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()), $settings['eael_excerpt_length'], $settings['excerpt_expanison_indicator'] ) . '</p>';
}
}
if ($settings['eael_show_read_more_button']) {
echo '<a
href="' . get_the_permalink() . '"
class="eael-post-elements-readmore-btn"' . $link_settings['read_more_link_nofollow'] . '' . $link_settings['read_more_link_target_blank'] . '>' . Helper::eael_wp_kses($settings['read_more_button_text']) . '</a>';
}
echo '</div>
</div>';
}
if ($settings['meta_position'] == 'meta-entry-footer') {
echo '<div class="eael-entry-header-after style-two">';
if ( isset( $settings['eael_show_avatar_two'] ) && 'yes' === $settings['eael_show_avatar_two'] ) {
echo '<div class="eael-author-avatar"><a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_avatar(get_the_author_meta('ID'), 96, '', get_the_author_meta( 'display_name' ) ) . '</a></div>';
}
echo '<div class="eael-entry-meta">';
if ( isset( $settings['eael_show_author_two'] ) && 'yes' === $settings['eael_show_author_two'] ) {
echo '<span class="eael-posted-by style-two-footer">' . $author_link . '</span>';
}
if ( 'yes' === $settings['eael_show_date'] ) {
echo '<span class="eael-meta-posted-on"><i class="far fa-clock"></i><time datetime="' . get_the_date() . '">' . get_the_date() . '</time></span>';
}
if ( 'yes' === $settings['eael_show_post_terms'] ) {
if ($settings['eael_post_terms'] === 'category') {
$terms = get_the_category();
}
if ($settings['eael_post_terms'] === 'tags') {
$terms = get_the_tags();
}
//For custom post type
$get_custom_post_type = get_post_type( get_the_ID() ); //post
if ( 'product' === $get_custom_post_type ) {
$get_custom_taxonomy = $settings['eael_post_terms'] === 'category' ? 'product_cat' : ( $settings['eael_post_terms'] === 'tags' ? 'product_tag' : $settings['eael_post_terms'] );
} else {
$get_custom_taxonomy = $settings["eael_{$get_custom_post_type}_terms"]; //tags
}
if( 'post' !== $get_custom_post_type && $settings[ 'eael_post_terms' ] === $get_custom_taxonomy ) {
$terms = wp_get_post_terms( get_the_ID(), $get_custom_taxonomy );
}
if (!empty($terms)) {
$html = '<ul class="post-meta-categories">';
$count = 0;
foreach ($terms as $term) {
if ($count === intval($settings['eael_post_terms_max_length'])) {
break;
}
if ($count === 0) {
$html .= '<li class="meta-cat-icon"><i class="far fa-folder-open"></i></li>';
}
$is_last_item = $count + 1 === intval($settings['eael_post_terms_max_length']) || $count + 1 === count( (array) $terms);
if ( ! empty( $term->name ) ) {
$eael_post_terms_separator = ! empty( $settings['eael_post_terms_separator'] ) ? wp_strip_all_tags( $settings['eael_post_terms_separator'] ) : '';
$eael_post_terms_separator = $is_last_item ? '' : $eael_post_terms_separator;
}
$link = ($settings['eael_post_terms'] === 'category') ? get_category_link($term->term_id) : get_tag_link($term->term_id);
$html .= '<li>';
$html .= '<a href="' . esc_url($link) . '">';
$html .= $term->name . " " . esc_html( $eael_post_terms_separator );
$html .= '</a>';
$html .= '</li>';
$count++;
}
$html .= '</ul>';
echo $html;
}
}
echo '</div>';
echo '</div>';
}
echo '</div>';
}
echo '</div>
</div>
</article>';
} else if ($settings['eael_post_grid_preset_style'] === 'three') {
echo '<article class="eael-grid-post eael-post-grid-column" data-id="' . get_the_ID() . '">
<div class="eael-grid-post-holder">
<div class="eael-grid-post-holder-inner">';
if ( $thumbnail_html && 'yes' === $settings['eael_show_image'] ) {
echo '<div class="eael-entry-media">';
if ( 'yes' === $settings['eael_post_terms_on_image_hover'] ) {
echo Helper::get_terms_as_list($settings['eael_post_terms'], $settings['eael_post_terms_max_length']);
}
echo '<div class="eael-entry-overlay ' . esc_attr( $settings['eael_post_grid_hover_animation'] ) . '">';
if (isset($settings['eael_post_grid_bg_hover_icon_new']['url'])) {
echo '<img src="' . esc_url($settings['eael_post_grid_bg_hover_icon_new']['url']) . '" alt="' . esc_attr(get_post_meta($settings['eael_post_grid_bg_hover_icon_new']['id'], '_wp_attachment_image_alt', true)) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['eael_post_grid_bg_hover_icon_new']['value'] ) . '" aria-hidden="true"></i>';
}
echo '<a href="' . get_the_permalink() . '"' . $link_settings['image_link_nofollow'] . '' . $link_settings['image_link_target_blank'] . '></a>';
echo '</div>';
echo '<div class="eael-entry-thumbnail '.$enable_ratio.'">
'.$thumbnail_html.'
</div>
</div>';
if ($settings['meta_position'] == 'meta-entry-header' && $settings['eael_show_date'] === 'yes') {
echo '<span class="eael-meta-posted-on"><time datetime="' . get_the_date() . '"><span>' . get_the_date('d') . '</span>' . get_the_date('F') . '</time></span>';
}
}
if ($settings['eael_show_title'] || $settings['eael_show_meta'] || $settings['eael_show_excerpt']) {
echo '<div class="eael-entry-wrapper">';
if ($settings['eael_show_title']) {
echo '<header class="eael-entry-header"><' . $title_tag . ' class="eael-entry-title">';
echo '<a
class="eael-grid-post-link"
href="' . get_the_permalink() . '"
title="' . strip_tags( get_the_title() ) . '"' . $link_settings['title_link_nofollow'] . '' . $link_settings['title_link_target_blank'] . '>';
if (empty($settings['eael_title_length'])) {
echo get_the_title();
} else {
echo implode(" ", array_slice(explode(" ", get_the_title()), 0, $settings['eael_title_length']));
}
echo '</a>';
/*
* used Helper::eael_validate_html_tag() method to validate $title_tag
*/
echo '</' . $title_tag . '></header>';
}
if ($settings['meta_position'] == 'meta-entry-footer') {
if ($settings['eael_show_meta']) {
echo '<div class="eael-entry-meta">';
if ( isset( $settings['eael_show_author_three'] ) && 'yes' === $settings['eael_show_author_three'] ) {
echo '<span class="eael-posted-by">' . $author_link . '</span>';
}
if ($settings['eael_show_date'] === 'yes') {
echo '<span class="eael-posted-on"><time datetime="' . get_the_date() . '">' . get_the_date() . '</time></span>';
}
echo '</div>';
}
}
if ($settings['eael_show_excerpt'] || $settings['eael_show_read_more_button']) {
echo '<div class="eael-entry-content">
<div class="eael-grid-post-excerpt">';
if ($settings['eael_show_excerpt']) {
if (empty($settings['eael_excerpt_length'])) {
echo '<p>' . strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()) . '</p>';
} else {
echo '<p>' . wp_trim_words( strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()), $settings['eael_excerpt_length'], $settings['excerpt_expanison_indicator']) . '</p>';
}
}
if ($settings['eael_show_read_more_button']) {
echo '<a
href="' . get_the_permalink() . '"
class="eael-post-elements-readmore-btn"' . $link_settings['read_more_link_nofollow'] . '' . $link_settings['read_more_link_target_blank'] . '>' . Helper::eael_wp_kses($settings['read_more_button_text']) . '</a>';
}
echo '</div>
</div>';
}
echo '</div>';
}
echo '</div>
</div>
</article>';
} else {
echo '<article class="eael-grid-post eael-post-grid-column" data-id="' . esc_attr( get_the_ID() ) . '">
<div class="eael-grid-post-holder">
<div class="eael-grid-post-holder-inner">';
if ( $thumbnail_html && 'yes' === $settings['eael_show_image'] ) {
echo '<div class="eael-entry-media">';
if ( 'yes' === $settings['eael_show_post_terms'] && 'yes' === $settings['eael_post_terms_on_image_hover'] ) {
echo Helper::get_terms_as_list($settings['eael_post_terms'], $settings['eael_post_terms_max_length']);
}
echo '<div class="eael-entry-overlay ' . esc_attr( $settings['eael_post_grid_hover_animation'] ) . '">';
if (isset($settings['eael_post_grid_bg_hover_icon_new']['url'])) {
echo '<img src="' . esc_url($settings['eael_post_grid_bg_hover_icon_new']['url']) . '" alt="' . esc_attr(get_post_meta($settings['eael_post_grid_bg_hover_icon_new']['id'], '_wp_attachment_image_alt', true)) . '" />';
} else {
if (($settings['eael_post_grid_bg_hover_icon_new']['library']) == 'svg') {
echo '<img src="' . esc_url($settings['eael_post_grid_bg_hover_icon_new']['value']['url']) . '" alt="' . esc_attr(get_post_meta($settings['eael_post_grid_bg_hover_icon_new']['value']['id'], '_wp_attachment_image_alt', true)) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['eael_post_grid_bg_hover_icon_new']['value'] ) . '" aria-hidden="true"></i>';
}
}
echo '<a href="' . get_the_permalink() . '"' . $link_settings['image_link_nofollow'] . '' . $link_settings['image_link_target_blank'] . '></a>';
echo '</div>';
echo '<div class="eael-entry-thumbnail '.$enable_ratio.'">
'.$thumbnail_html.'
</div>
</div>';
}
if ($settings['eael_show_title'] || $settings['eael_show_meta'] || $settings['eael_show_excerpt']) {
echo '<div class="eael-entry-wrapper">';
if ($settings['eael_show_title']) {
echo '<header class="eael-entry-header"><' . $title_tag . ' class="eael-entry-title">';
echo '<a
class="eael-grid-post-link"
href="' . get_the_permalink() . '"
title="' . strip_tags( get_the_title() ) . '"' . $link_settings['title_link_nofollow'] . '' . $link_settings['title_link_target_blank'] . '>';
if (empty($settings['eael_title_length'])) {
echo get_the_title();
} else {
echo implode(" ", array_slice(explode(" ", get_the_title()), 0, $settings['eael_title_length']));
}
echo '</a>';
echo '</' . $title_tag . '></header>';
}
if ($settings['meta_position'] == 'meta-entry-header') {
echo '<div class="eael-entry-header-after">';
if ( isset( $settings['eael_show_avatar'] ) && 'yes' === $settings['eael_show_avatar'] ) {
echo '<div class="eael-author-avatar"><a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_avatar(get_the_author_meta('ID'), 96, '', get_the_author_meta( 'display_name' ) ) . '</a></div>';
}
if ($settings['eael_show_meta']) {
echo '<div class="eael-entry-meta">';
if ( isset( $settings['eael_show_author'] ) && 'yes' === $settings['eael_show_author'] ) {
echo '<span class="eael-posted-by">' . $author_link . '</span>';
}
if ($settings['eael_show_date'] === 'yes') {
echo '<span class="eael-posted-on"><time datetime="' . get_the_date() . '">' . get_the_date() . '</time></span>';
}
echo '</div>';
}
echo '</div>';
}
if ($settings['eael_show_excerpt'] || $settings['eael_show_read_more_button']) {
echo '<div class="eael-entry-content">
<div class="eael-grid-post-excerpt">';
if ($settings['eael_show_excerpt']) {
if (empty($settings['eael_excerpt_length'])) {
echo '<p>' . strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()) . '</p>';
} else {
echo '<p>' . wp_trim_words( strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()), $settings['eael_excerpt_length'], $settings['excerpt_expanison_indicator']) . '</p>';
}
}
if ($settings['eael_show_read_more_button']) {
echo '<a
href="' . get_the_permalink() . '"
class="eael-post-elements-readmore-btn"' . $link_settings['read_more_link_nofollow'] . '' . $link_settings['read_more_link_target_blank'] . '>' . Helper::eael_wp_kses($settings['read_more_button_text']) . '</a>';
}
echo '</div>
</div>';
}
if ($settings['eael_show_meta'] && $settings['meta_position'] == 'meta-entry-footer') {
echo '<div class="eael-entry-footer">';
if ( isset( $settings['eael_show_avatar'] ) && 'yes' === $settings['eael_show_avatar'] ) {
echo '<div class="eael-author-avatar"><a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_avatar(get_the_author_meta('ID'), 96, '', get_the_author_meta( 'display_name' ) ) . '</a></div>';
}
if ($settings['eael_show_meta']) {
echo '<div class="eael-entry-meta">';
if ( isset( $settings['eael_show_author'] ) && 'yes' === $settings['eael_show_author'] ) {
echo '<span class="eael-posted-by">' . $author_link . '</span>';
}
if ($settings['eael_show_date'] === 'yes') {
echo '<span class="eael-posted-on"><time datetime="' . get_the_date() . '">' . get_the_date() . '</time></span>';
}
echo '</div>';
}
echo '</div>';
}
echo '</div>';
}
echo '</div>
</div>
</article>';
}

View File

@@ -0,0 +1,52 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Card
*/
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
$image = '';
if ($settings['eael_show_image'] == 'yes' && has_post_thumbnail()) {
$image = '<div class="eael-timeline-post-image" style="background-image: url('. wp_get_attachment_image_url
(get_post_thumbnail_id(),
$settings['image_size']) .')"></div>';
}
$title_tag = isset($settings['title_tag']) ? Helper::eael_validate_html_tag($settings['title_tag']) : 'h2';
echo '<article class="eael-timeline-post">
<div class="eael-timeline-bullet"></div>
<div class="eael-timeline-post-inner">
<a class="eael-timeline-post-link" href="' . get_the_permalink() . '" title="' . esc_html(get_the_title()) . '"' . ($settings['timeline_link_nofollow'] ? 'rel="nofollow"' : '') .'' . ($settings['timeline_link_target_blank'] ? 'target="_blank"' : '') . '>
<time datetime="' . get_the_date() . '">' . get_the_date() . '</time>
'. $image;
if( $settings['eael_show_title'] || $settings['eael_show_excerpt'] ) {
echo '<div class="eael-timeline-content">';
if ( $settings['eael_show_title'] ) {
echo '<div class="eael-timeline-post-title">
<' . $title_tag . ' class="' . esc_attr( 'eael-timeline-post-title-text-card' ) . '" >' . get_the_title() . '</'.$title_tag.'>
</div>';
}
if ( $settings['eael_show_excerpt'] ) {
echo '<div class="eael-timeline-post-excerpt">';
if ( empty( $settings['eael_excerpt_length'] ) ) {
echo '<p>' . strip_shortcodes( get_the_excerpt() ? get_the_excerpt() : get_the_content() ) . '</p>';
} else {
echo '<p>' . wp_trim_words( strip_shortcodes( get_the_excerpt() ? get_the_excerpt() : get_the_content() ), $settings['eael_excerpt_length'], $settings['expanison_indicator'] ) . '</p>';
}
echo '</div>';
}
echo '</div>';
}
echo '</a>
</div>
<div class="eael-timeline-clear"></div>
</article>';

View File

@@ -0,0 +1,46 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Default
*/
use Elementor\Group_Control_Image_Size;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
$post_timeline_image_url = Group_Control_Image_Size::get_attachment_image_src( get_post_thumbnail_id(),
'image', $settings );
$image_size = sanitize_html_class( $settings['image_size'] );
$image_class = " attachment-$image_size size-$image_size";
$title_tag = isset($settings['title_tag']) ? Helper::eael_validate_html_tag($settings['title_tag']) : 'h2';
echo '<article class="eael-timeline-post eael-timeline-column">
<div class="eael-timeline-bullet"></div>
<div class="eael-timeline-post-inner">
<a class="eael-timeline-post-link" href="' . get_the_permalink() . '" title="' . esc_attr(get_the_title()) . '"' . ($settings['timeline_link_nofollow'] ? 'rel="nofollow"' : '') .'' . ($settings['timeline_link_target_blank'] ? 'target="_blank"' : '') . '>
<time datetime="' . get_the_date() . '">' . get_the_date() . '</time>
<div class="eael-timeline-post-image'.$image_class.'" ' . ($settings['eael_show_image'] == 'yes' ? 'style="background-image: url('.esc_url( $post_timeline_image_url ).');"' : null) . '></div>';
if ($settings['eael_show_excerpt']) {
echo '<div class="eael-timeline-post-excerpt">';
if(empty($settings['eael_excerpt_length'])) {
echo '<p>'.strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()).'</p>';
}else {
echo '<p>' . wp_trim_words(strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()), intval( $settings['eael_excerpt_length'] ), sanitize_text_field( $settings['expanison_indicator'] )) . '</p>';
}
echo '</div>';
}
if ($settings['eael_show_title']) {
echo '<div class="eael-timeline-post-title">
<' . Helper::eael_validate_html_tag( $settings['title_tag'] ) . ' class="eael-timeline-post-title-text">' . get_the_title() . '</' . Helper::eael_validate_html_tag( $settings['title_tag'] ) . '>
</div>';
}
echo '</a>
</div>
</article>';

View File

@@ -0,0 +1,125 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Preset 1
*/
use Essential_Addons_Elementor\Elements\Woo_Product_carousel;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
// Improvement
$sale_badge_align = isset( $settings['eael_product_sale_badge_alignment'] ) ? $settings['eael_product_sale_badge_alignment'] : '';
$sale_badge_preset = isset($settings['eael_product_sale_badge_preset']) ? $settings['eael_product_sale_badge_preset'] : '';
$sale_text = !empty($settings['eael_product_carousel_sale_text']) ? $settings['eael_product_carousel_sale_text'] : 'Sale!';
$stockout_text = !empty($settings['eael_product_carousel_stockout_text']) ? $settings['eael_product_carousel_stockout_text'] : 'Stock Out';
// should print vars
$should_print_rating = isset( $settings['eael_product_carousel_rating'] ) && 'yes' === $settings['eael_product_carousel_rating'];
$should_print_quick_view = isset( $settings['eael_product_carousel_quick_view'] ) && 'yes' === $settings['eael_product_carousel_quick_view'];
$should_print_image_clickable = isset( $settings['eael_product_carousel_image_clickable'] ) && 'yes' === $settings['eael_product_carousel_image_clickable'];
$should_print_title_clickable = isset( $settings['eael_product_carousel_title_clickable'] ) && 'yes' === $settings['eael_product_carousel_title_clickable'];
$should_print_price = isset( $settings['eael_product_carousel_price'] ) && 'yes' === $settings['eael_product_carousel_price'];
$should_print_excerpt = isset( $settings['eael_product_carousel_excerpt'] ) && ('yes' === $settings['eael_product_carousel_excerpt'] && has_excerpt());
$widget_id = isset($settings['eael_widget_id']) ? $settings['eael_widget_id'] : null;
$quick_view_setting = [
'widget_id' => $widget_id,
'product_id' => $product->get_id(),
'page_id' => $settings['eael_page_id'],
];
$product_details_wrap_show = ! empty( $settings['eael_product_carousel_show_title'] ) || $should_print_price || $should_print_rating || $should_print_excerpt;
$product_details_none_class = $product_details_wrap_show ? '' : 'product-details-none';
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li <?php post_class( ['product', 'swiper-slide'] ); ?>>
<div class="eael-product-carousel <?php echo esc_attr( $product_details_none_class ); ?>">
<div class="product-image-wrap">
<div class="image-wrap">
<?php
echo( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $stockout_text ) . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $sale_text ) . '</span>' : '' ) );
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo $product->get_image($settings['eael_product_carousel_image_size_size'], ['loading' => 'eager']);
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
<div class="image-hover-wrap">
<ul class="icons-wrap box-style">
<?php if( $settings[ 'eael_product_carousel_show_add_to_cart' ] ) { ?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<li class="view-details" title="Details"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
</ul>
<?php
?>
</div>
</div>
<div class="product-details-wrap">
<div class="product-details">
<?php
if ( $settings['eael_product_carousel_show_title'] ) {
echo '<div class="eael-product-title">';
if( $should_print_title_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo '<' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if ( empty( $settings['eael_product_carousel_title_length'] ) ) {
echo Helper::eael_wp_kses( $product->get_title() );
} else {
echo implode( " ", array_slice( explode( " ", Helper::eael_wp_kses($product->get_title()) ), 0, $settings['eael_product_carousel_title_length'] ) );
}
echo '</' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if( $should_print_title_clickable ) {
echo '</a>';
}
echo '</div>';
}
?>
<?php if ($should_print_rating) {
echo wc_get_rating_html($product->get_average_rating(), $product->get_rating_count());
}
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words( strip_shortcodes( get_the_excerpt() ), $settings['eael_product_carousel_excerpt_length'],
esc_html( $settings['eael_product_carousel_excerpt_expanison_indicator'] ) ) . '</p>';
echo '</div>';
}
?>
</div>
<?php if($should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}?>
</div>
</div>
</li>
<?php
}

View File

@@ -0,0 +1,126 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Preset 2
*/
use Essential_Addons_Elementor\Elements\Woo_Product_Carousel;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
// Improvement
$sale_badge_align = isset( $settings['eael_product_sale_badge_alignment'] ) ? $settings['eael_product_sale_badge_alignment'] : '';
$sale_badge_preset = isset($settings['eael_product_sale_badge_preset']) ? $settings['eael_product_sale_badge_preset'] : '';
$sale_text = !empty($settings['eael_product_carousel_sale_text']) ? $settings['eael_product_carousel_sale_text'] : 'Sale!';
$stockout_text = !empty($settings['eael_product_carousel_stockout_text']) ? $settings['eael_product_carousel_stockout_text'] : 'Stock Out';
// should print vars
$should_print_rating = isset( $settings['eael_product_carousel_rating'] ) && 'yes' === $settings['eael_product_carousel_rating'];
$should_print_quick_view = isset( $settings['eael_product_carousel_quick_view'] ) && 'yes' === $settings['eael_product_carousel_quick_view'];
$should_print_image_clickable = isset( $settings['eael_product_carousel_image_clickable'] ) && 'yes' === $settings['eael_product_carousel_image_clickable'];
$should_print_title_clickable = isset( $settings['eael_product_carousel_title_clickable'] ) && 'yes' === $settings['eael_product_carousel_title_clickable'];
$should_print_price = isset( $settings['eael_product_carousel_price'] ) && 'yes' === $settings['eael_product_carousel_price'];
$should_print_excerpt = isset( $settings['eael_product_carousel_excerpt'] ) && ('yes' === $settings['eael_product_carousel_excerpt'] && has_excerpt());
$widget_id = isset($settings['eael_widget_id']) ? $settings['eael_widget_id'] : null;
$quick_view_setting = [
'widget_id' => $widget_id,
'product_id' => $product->get_id(),
'page_id' => $settings['eael_page_id'],
];
$product_details_wrap_show = ! empty( $settings['eael_product_carousel_show_title'] ) || $should_print_price || $should_print_rating || $should_print_excerpt;
$product_details_none_class = $product_details_wrap_show ? '' : 'product-details-none-overlay';
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li <?php post_class( ['product', 'swiper-slide'] ); ?>>
<div class="eael-product-carousel <?php echo esc_attr( $product_details_none_class ); ?>">
<div class="carousel-overlay <?php echo $should_print_image_clickable ? 'eael-img-clickable' : ''; ?>"></div>
<div class="product-image-wrap">
<div class="image-wrap">
<?php
echo( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $stockout_text ) . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $sale_text ) . '</span>' : '' ) );
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo $product->get_image($settings['eael_product_carousel_image_size_size'], ['loading' => 'eager']);
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
<div class="image-hover-wrap">
<ul class="icons-wrap box-style-list">
<?php if( $settings[ 'eael_product_carousel_show_add_to_cart' ] ) { ?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<li class="view-details" title="Details"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
</ul>
</div>
</div>
<div class="product-overlay-content">
<div class="product-details-wrap">
<div class="eael-product-title-wrap">
<?php
if ( $settings['eael_product_carousel_show_title'] ) {
echo '<div class="eael-product-title">';
if( $should_print_title_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo '<' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if ( empty( $settings['eael_product_carousel_title_length'] ) ) {
echo Helper::eael_wp_kses( $product->get_title() );
} else {
echo implode( " ", array_slice( explode( " ", Helper::eael_wp_kses($product->get_title()) ), 0, $settings['eael_product_carousel_title_length'] ) );
}
echo '</' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if( $should_print_title_clickable ) {
echo '</a>';
}
echo '</div>';
}
?>
<?php if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
} ?>
</div>
<?php if($should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words( strip_shortcodes( get_the_excerpt() ), $settings['eael_product_carousel_excerpt_length'],
esc_html( $settings['eael_product_carousel_excerpt_expanison_indicator'] ) ) . '</p>';
echo '</div>';
}
?>
</div>
</div>
</div>
</li>
<?php
}

View File

@@ -0,0 +1,122 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Preset 3
*/
use Essential_Addons_Elementor\Elements\Woo_Product_carousel;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
// Improvement
$sale_badge_align = isset( $settings['eael_product_sale_badge_alignment'] ) ? $settings['eael_product_sale_badge_alignment'] : '';
$sale_badge_preset = isset($settings['eael_product_sale_badge_preset']) ? $settings['eael_product_sale_badge_preset'] : '';
$sale_text = !empty($settings['eael_product_carousel_sale_text']) ? $settings['eael_product_carousel_sale_text'] : 'Sale!';
$stockout_text = !empty($settings['eael_product_carousel_stockout_text']) ? $settings['eael_product_carousel_stockout_text'] : 'Stock Out';
// should print vars
$should_print_rating = isset( $settings['eael_product_carousel_rating'] ) && 'yes' === $settings['eael_product_carousel_rating'];
$should_print_quick_view = isset( $settings['eael_product_carousel_quick_view'] ) && 'yes' === $settings['eael_product_carousel_quick_view'];
$should_print_image_clickable = isset( $settings['eael_product_carousel_image_clickable'] ) && 'yes' === $settings['eael_product_carousel_image_clickable'];
$should_print_title_clickable = isset( $settings['eael_product_carousel_title_clickable'] ) && 'yes' === $settings['eael_product_carousel_title_clickable'];
$should_print_price = isset( $settings['eael_product_carousel_price'] ) && 'yes' === $settings['eael_product_carousel_price'];
$should_print_excerpt = isset( $settings['eael_product_carousel_excerpt'] ) && ('yes' === $settings['eael_product_carousel_excerpt'] && has_excerpt());
$widget_id = isset($settings['eael_widget_id']) ? $settings['eael_widget_id'] : null;
$quick_view_setting = [
'widget_id' => $widget_id,
'product_id' => $product->get_id(),
'page_id' => $settings['eael_page_id'],
];
$product_details_wrap_show = ! empty( $settings['eael_product_carousel_show_title'] ) || $should_print_price || $should_print_rating || $should_print_excerpt;
$product_details_none_class = $product_details_wrap_show ? '' : 'product-details-none';
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li <?php post_class( ['product', 'swiper-slide'] ); ?>>
<div class="eael-product-carousel <?php echo esc_attr( $product_details_none_class ); ?>">
<div class="product-image-wrap">
<div class="image-wrap">
<?php
echo ( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $stockout_text ) . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $sale_text ) . '</span>' : '' ) );
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo $product->get_image($settings['eael_product_carousel_image_size_size'], ['loading' => 'eager']);
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
<div class="image-hover-wrap">
<ul class="icons-wrap block-style">
<?php if( $settings[ 'eael_product_carousel_show_add_to_cart' ] ) { ?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<li class="view-details"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
</ul>
<?php
?>
</div>
</div>
<div class="product-details-wrap">
<?php
if ( $settings['eael_product_carousel_show_title'] ) {
echo '<div class="eael-product-title">';
if( $should_print_title_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo '<' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if ( empty( $settings['eael_product_carousel_title_length'] ) ) {
echo Helper::eael_wp_kses( $product->get_title() );
} else {
echo implode( " ", array_slice( explode( " ", Helper::eael_wp_kses($product->get_title()) ), 0, $settings['eael_product_carousel_title_length'] ) );
}
echo '</' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if( $should_print_title_clickable ) {
echo '</a>';
}
echo '</div>';
}
?>
<?php if($should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}?>
<?php if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words( strip_shortcodes( get_the_excerpt() ), $settings['eael_product_carousel_excerpt_length'],
esc_html( $settings['eael_product_carousel_excerpt_expanison_indicator'] ) ) . '</p>';
echo '</div>';
}
?>
</div>
</div>
</li>
<?php
}

View File

@@ -0,0 +1,129 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Preset 4
*/
use Essential_Addons_Elementor\Elements\Woo_Product_carousel;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
// Improvement
$sale_badge_align = isset( $settings['eael_product_sale_badge_alignment'] ) ? $settings['eael_product_sale_badge_alignment'] : '';
$sale_badge_preset = isset($settings['eael_product_sale_badge_preset']) ? $settings['eael_product_sale_badge_preset'] : '';
$sale_text = !empty($settings['eael_product_carousel_sale_text']) ? $settings['eael_product_carousel_sale_text'] : 'Sale!';
$stockout_text = !empty($settings['eael_product_carousel_stockout_text']) ? $settings['eael_product_carousel_stockout_text'] : 'Stock Out';
// should print vars
$should_print_rating = isset( $settings['eael_product_carousel_rating'] ) && 'yes' === $settings['eael_product_carousel_rating'];
$should_print_quick_view = isset( $settings['eael_product_carousel_quick_view'] ) && 'yes' === $settings['eael_product_carousel_quick_view'];
$should_print_image_clickable = isset( $settings['eael_product_carousel_image_clickable'] ) && 'yes' === $settings['eael_product_carousel_image_clickable'];
$should_print_title_clickable = isset( $settings['eael_product_carousel_title_clickable'] ) && 'yes' === $settings['eael_product_carousel_title_clickable'];
$should_print_price = isset( $settings['eael_product_carousel_price'] ) && 'yes' === $settings['eael_product_carousel_price'];
$should_print_excerpt = isset( $settings['eael_product_carousel_excerpt'] ) && ('yes' === $settings['eael_product_carousel_excerpt'] && has_excerpt());
$widget_id = isset($settings['eael_widget_id']) ? $settings['eael_widget_id'] : null;
$quick_view_setting = [
'widget_id' => $widget_id,
'product_id' => $product->get_id(),
'page_id' => $settings['eael_page_id'],
];
$product_details_wrap_show = ! empty( $settings['eael_product_carousel_show_title'] ) || $should_print_price || $should_print_rating || $should_print_excerpt;
$product_details_none_class = $product_details_wrap_show ? '' : 'product-details-none-overlay';
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li <?php post_class( ['product', 'swiper-slide'] ); ?>>
<div class="eael-product-carousel <?php echo esc_attr( $product_details_none_class ); ?>">
<div class="carousel-overlay <?php echo $should_print_image_clickable ? 'eael-img-clickable' : ''; ?>"></div>
<div class="product-image-wrap">
<div class="image-wrap">
<?php
echo ( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $stockout_text ) . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $sale_text ) . '</span>' : '' ) );
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo $product->get_image($settings['eael_product_carousel_image_size_size'], ['loading' => 'eager']);
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
</div>
<div class="product-overlay-content">
<div class="product-details-wrap">
<div class="product-details">
<div class="eael-product-title-wrap">
<?php
if ( $settings['eael_product_carousel_show_title'] ) {
echo '<div class="eael-product-title">';
if( $should_print_title_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo '<' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if ( empty( $settings['eael_product_carousel_title_length'] ) ) {
echo Helper::eael_wp_kses( $product->get_title() );
} else {
echo implode( " ", array_slice( explode( " ", Helper::eael_wp_kses($product->get_title()) ), 0, $settings['eael_product_carousel_title_length'] ) );
}
echo '</' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if( $should_print_title_clickable ) {
echo '</a>';
}
echo '</div>';
}
?>
<?php if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
} ?>
</div>
<?php if($should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
} ?>
</div>
<?php if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words( strip_shortcodes( get_the_excerpt() ), $settings['eael_product_carousel_excerpt_length'],
esc_html( $settings['eael_product_carousel_excerpt_expanison_indicator'] ) ) . '</p>';
echo '</div>';
}
?>
<div class="buttons-wrap">
<ul class="icons-wrap box-style">
<?php if( $settings[ 'eael_product_carousel_show_add_to_cart' ] ) { ?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<li class="view-details" title="Details"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
</ul>
</div>
</div>
</div>
</div>
</li>
<?php
}

View File

@@ -0,0 +1,276 @@
<?php
/**
* Template Name: Default
*/
use \Essential_Addons_Elementor\Classes\Helper;
use Essential_Addons_Elementor\Elements\Woo_Product_Gallery;
use \Elementor\Group_Control_Image_Size;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
if ( has_post_thumbnail() ) {
$settings[ 'eael_image_size_customize' ] = [
'id' => get_post_thumbnail_id(),
];
$settings['eael_image_size_customize_size'] = $settings['eael_product_gallery_image_size_size'];
$thumbnail_html = Group_Control_Image_Size::get_attachment_image_html( $settings,'eael_image_size_customize' );
}
$title_tag = isset( $settings['eael_product_gallery_title_html_tag'] ) ? Helper::eael_validate_html_tag($settings['eael_product_gallery_title_html_tag']) : 'h2';
// Improvement
$gallery_style_preset = isset($settings['eael_product_gallery_style_preset']) ? $settings['eael_product_gallery_style_preset'] : '';
$sale_badge_align = isset( $settings['eael_product_sale_badge_alignment'] ) ? $settings['eael_product_sale_badge_alignment'] : '';
$sale_badge_preset = isset($settings['eael_product_sale_badge_preset']) ? $settings['eael_product_sale_badge_preset'] : '';
// should print vars
$sale_text = !empty($settings['eael_product_gallery_sale_text']) ? $settings['eael_product_gallery_sale_text'] : 'Sale!';
$stockout_text = !empty($settings['eael_product_gallery_stockout_text']) ? $settings['eael_product_gallery_stockout_text'] : 'Stock <br/> Out';
$should_print_rating = isset( $settings['eael_product_gallery_rating'] ) && 'yes' === $settings['eael_product_gallery_rating'];
$should_print_quick_view = isset( $settings['eael_product_gallery_quick_view'] ) && 'yes' === $settings['eael_product_gallery_quick_view'];
$should_print_addtocart = isset( $settings['eael_product_gallery_addtocart_show'] ) && 'yes' === $settings['eael_product_gallery_addtocart_show'];
$should_print_link = isset( $settings['eael_product_gallery_link_show'] ) && 'yes' === $settings['eael_product_gallery_link_show'];
$should_print_image_clickable = isset( $settings['eael_product_gallery_image_clickable'] ) && 'yes' === $settings['eael_product_gallery_image_clickable'];
$should_print_price = isset( $settings['eael_product_gallery_price'] ) && 'yes' === $settings['eael_product_gallery_price'];
$widget_id = isset($settings['eael_widget_id']) ? $settings['eael_widget_id'] : null;
$quick_view_setting = [
'widget_id' => $widget_id,
'product_id' => $product->get_id(),
'page_id' => $settings['eael_page_id'],
];
$show_secondary_image = isset( $settings['eael_product_gallery_show_secondary_image'] ) && 'yes' === $settings['eael_product_gallery_show_secondary_image'];
$image_sources = [
'src' => '',
'src_hover' => ''
];
//if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
$product_wrapper_classes = implode( " ", apply_filters( 'eael_product_wrapper_class', [], $product->get_id(), 'eael-woo-product-gallery' ) );
if ( $gallery_style_preset == 'eael-product-preset-4' ) { ?>
<li class="product <?php echo esc_attr( $product_wrapper_classes ) ?>">
<?php
if($show_secondary_image){
$image_sources = Helper::eael_get_woo_product_gallery_image_srcs( $product, $settings['eael_product_gallery_image_size_size'] );
}
?>
<div class="eael-product-wrap" data-src="<?php echo esc_url( $image_sources['src'] ); ?>" data-src-hover="<?php echo esc_url( $image_sources['src_hover'] ) ?>" >
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ){
do_action( 'woocommerce_before_shop_loop_item' );
}
echo ( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock '. esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) .'">'. Helper::eael_wp_kses($stockout_text) .'</span>' : ($product->is_on_sale() ? '<span class="eael-onsale '. esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) .'">' . Helper::eael_wp_kses($sale_text) . '</span>' : '') );
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}?>
<?php
echo $product->get_image( $settings['eael_product_gallery_image_size_size'], ['loading' => 'eager', 'alt' => esc_attr( $product->get_title() ) ] );
if ( $should_print_image_clickable ) {
echo '</a>';
}
printf('<%1$s class="woocommerce-loop-product__title">%2$s</%1$s>', $title_tag, Helper::eael_wp_kses($product->get_title()));
if ( $should_print_rating ) {
echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) );
}
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
?>
<?php
if ( $should_print_addtocart ) {
woocommerce_template_loop_add_to_cart();
}
if ( $settings['eael_wc_loop_hooks'] === 'yes' ){
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</div>
</li>
<?php
} else if (($gallery_style_preset == 'eael-product-preset-3') || ($gallery_style_preset == 'eael-product-preset-2')) {
?>
<li <?php post_class( "product {$product_wrapper_classes}" ); ?>>
<?php
if( $show_secondary_image ){
$image_sources = Helper::eael_get_woo_product_gallery_image_srcs( $product, $settings['eael_product_gallery_image_size_size'] );
}
?>
<div class="eael-product-wrap" data-src="<?php echo esc_url( $image_sources['src'] ); ?>" data-src-hover="<?php echo esc_url( $image_sources['src_hover'] ); ?>" >
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_before_shop_loop_item' );
}
?>
<div class="product-image-wrap">
<div class="image-wrap">
<?php if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo ( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock '. esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) .'">'. Helper::eael_wp_kses( $stockout_text ) .'</span>' : ($product->is_on_sale() ? '<span class="eael-onsale '. esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) .'">' . Helper::eael_wp_kses($sale_text) . '</span>' : '') );
echo $product->get_image( $settings['eael_product_gallery_image_size_size'], ['loading' => 'eager', 'alt' => esc_attr( $product->get_title() ) ] );
if( $should_print_image_clickable ) {
echo '</a>';
}?>
</div>
<div class="image-hover-wrap">
<?php if ($gallery_style_preset == 'eael-product-preset-2') { ?>
<ul class="icons-wrap block-box-style">
<?php if( $should_print_addtocart ){?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php } ?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-gallery-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<?php if( $should_print_link ){?>
<li class="view-details"><?php echo '<a href="' . $product->get_permalink() . '" aria-label="View Details about ' . esc_attr( $product->get_title() ) . '"><i class="fas fa-link"></i></a>'; ?></li>
<?php } ?>
</ul>
<?php } else { ?>
<ul class="icons-wrap box-style">
<?php if( $should_print_addtocart ){?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php } ?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-gallery-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<?php if( $should_print_link ){?>
<li class="view-details" title="Details" aria-label="View Details about <?php echo esc_attr( $product->get_title() ); ?>"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
<?php } ?>
</ul>
<?php }
?>
</div>
</div>
<div class="product-details-wrap">
<?php
if(($gallery_style_preset == 'eael-product-preset-2') && $should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
?>
<div class="eael-product-title">
<?php printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ) ); ?>
</div>
<?php if(($gallery_style_preset != 'eael-product-preset-2') && $should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}?>
</div>
<?php
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</div>
</li>
<?php
} else if ($gallery_style_preset == 'eael-product-preset-1') {
?>
<li <?php post_class( "product {$product_wrapper_classes}" ); ?>>
<?php
if( $show_secondary_image ){
$image_sources = Helper::eael_get_woo_product_gallery_image_srcs( $product, $settings['eael_product_gallery_image_size_size'] );
}
?>
<div class="eael-product-wrap" data-src="<?php echo esc_url( $image_sources['src'] ); ?>" data-src-hover="<?php echo esc_url( $image_sources['src_hover'] ); ?>" >
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_before_shop_loop_item' );
}
?>
<div class="product-image-wrap">
<div class="image-wrap">
<?php if ( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . Helper::eael_wp_kses( $stockout_text ) . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . Helper::eael_wp_kses( $sale_text ) . '</span>' : '' ) );
echo $product->get_image( $settings['eael_product_gallery_image_size_size'], ['loading' => 'eager', 'alt' => esc_attr( $product->get_title() )] );
if ( $should_print_image_clickable ) {
echo '</a>';
} ?>
</div>
<div class="image-hover-wrap">
<ul class="icons-wrap over-box-style">
<?php if( $should_print_addtocart ){?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php } ?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-gallery-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<?php if( $should_print_link ){?>
<li class="view-details"><?php echo '<a href="' . $product->get_permalink() . '" aria-label="View Details about ' . esc_attr( $product->get_title() ) . '" ><i class="fas fa-link"></i></a>'; ?></li>
<?php } ?>
</ul>
</div>
</div>
<div class="product-details-wrap">
<?php
if ( $should_print_price ) {
echo '<div class="eael-product-price">' . $product->get_price_html() . '</div>';
}
?>
<div class="eael-product-title">
<?php
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ) );
echo '</a>';
?>
</div>
</div>
<?php
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</div>
</li>
<?php
}
//}

View File

@@ -0,0 +1,147 @@
<?php
/**
* Template Name: Preset 1
*/
use Essential_Addons_Elementor\Elements\Woo_Product_List;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( empty( $woo_product_list ) ) {
$woo_product_list = Woo_Product_List::get_woo_product_list_settings( $settings );
}
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
$woo_product_list_loop = Woo_Product_List::get_woo_product_list_loop_settings( $product, $settings, $woo_product_list ); // static method as the template is used by read more feature too
?>
<div <?php post_class( 'product' ); ?>>
<div class="eael-product-list-item <?php echo esc_attr( $woo_product_list['image_alignment'] ); ?>">
<?php if( 'badge-preset-2' === $woo_product_list['badge_preset'] ) : ?>
<?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?>
<?php endif; ?>
<div class="eael-product-list-image-wrap">
<?php if( 'badge-preset-2' !== $woo_product_list['badge_preset'] ) : ?>
<?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?>
<?php endif; ?>
<?php if ( $woo_product_list['image_clickable'] ) : ?>
<a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="woocommerce-LoopProduct-link woocommerce-loop-product__link" >
<?php endif; ?>
<?php echo wp_kses_post( $product->get_image( $woo_product_list['image_size'], ['loading' => 'eager'] ) ); ?>
<?php if ( $woo_product_list['image_clickable'] ) : ?>
</a>
<?php endif; ?>
<?php if ( $woo_product_list['button_position_on_hover'] ) : ?>
<ul class="eael-product-list-buttons-on-hover">
<?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?>
<li class="eael-product-list-add-to-cart-button eael-m-0">
<?php woocommerce_template_loop_add_to_cart(); ?>
</li>
<?php endif; ?>
<?php if ( $woo_product_list['quick_view_button_show'] ) : ?>
<li class="eael-product-list-quick-view-button eael-m-0">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars( json_encode( $woo_product_list_loop['quick_view_setting'] ), ENT_QUOTES ); ?>" class="open-popup-link"><i class="fas fa-eye"></i></a>
</li>
<?php endif; ?>
<?php if ( $woo_product_list['link_button_show'] ) : ?>
<li class="eael-product-list-link-button eael-m-0">
<a href="<?php echo esc_url( $product->get_permalink() ); ?>"><i class="fas fa-link"></i></a>
</li>
<?php endif; ?>
</ul>
<?php endif; ?>
</div>
<div class="eael-product-list-content-wrap">
<?php
if ( 'after-title' === $woo_product_list['content_header_position'] ) :
Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product );
endif;
?>
<div class="eael-product-list-content-header <?php echo esc_attr( $woo_product_list_loop['direction_rtl_class'] ) ?>" >
<?php if ( $woo_product_list['rating_show'] ) : ?>
<div class="eael-product-list-rating">
<?php echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) ); ?>
<?php if ( $woo_product_list['review_count_show'] && $woo_product_list_loop['review_count'] > 0 ) : ?>
<a href="<?php echo esc_url( get_permalink() ) ?>#reviews" class="woocommerce-review-link eael-product-list-review-count" rel="nofollow">(<?php printf( '%s', __( $woo_product_list_loop['review_count'], 'essential-addons-for-elementor-lite' ) ); ?>)</a>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="eael-product-list-notice eael-product-list-notice-shiping-free">
<?php if ( $woo_product_list['category_show'] && $woo_product_list_loop['has_terms'] ) : ?>
<p>
<i class="fas fa-box"></i>
<?php echo esc_html( Woo_Product_List::eael_get_product_category_name( $woo_product_list_loop['terms'] ) ); ?>
</p>
<?php endif; ?>
</div>
</div>
<div class="eael-product-list-content-body">
<?php
if ( 'before-title' === $woo_product_list['content_header_position'] ) :
Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product );
endif;
?>
<?php if ( $woo_product_list['excerpt_show'] ) : ?>
<div class="eael-product-list-excerpt">
<?php echo wp_trim_words( strip_shortcodes( get_the_excerpt() ), $woo_product_list['excerpt_words_count'], $woo_product_list['excerpt_expanison_indicator'] ); ?>
</div>
<?php endif; ?>
<?php if ( $woo_product_list['price_show'] ) : ?>
<h3 class="eael-product-list-price">
<?php echo wp_kses_post( $product->get_price_html() ); ?>
</h3>
<?php endif; ?>
</div>
<div class="eael-product-list-content-footer">
<?php if ( $woo_product_list['total_sold_show'] ) : ?>
<div class="eael-product-list-progress">
<div class="eael-product-list-progress-info">
<h4 class="eael-product-list-progress-count"><?php esc_html_e( $woo_product_list['total_sold_text'], 'essential-addons-for-elementor-lite' ); ?> <span><?php echo esc_html( $woo_product_list_loop['total_sales_count'] ); ?></span></h4>
<?php if( $product->managing_stock() && $woo_product_list['total_sold_remaining_show'] ) : ?>
<h4 class="eael-product-list-progress-remaining"><?php esc_html_e( $woo_product_list['total_sold_remaining_text'], 'essential-addons-for-elementor-lite' ); ?> <span><?php echo esc_html( $woo_product_list_loop['stock_quantity_count'] ); ?></span></h4>
<?php endif; ?>
</div>
<div class="eael-product-list-progress-bar-outer">
<div style="width: <?php echo esc_attr( $woo_product_list_loop['total_sold_progress_percentage'] ); ?>%;" class="eael-product-list-progress-bar-inner"></div>
</div>
</div>
<?php endif; ?>
<?php if ( $woo_product_list['button_position_static'] ) : ?>
<div class="eael-product-list-buttons">
<?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?>
<p class="eael-product-list-add-to-cart-button eael-m-0"><?php woocommerce_template_loop_add_to_cart(); ?></p>
<?php endif; ?>
<?php if ( $woo_product_list['quick_view_button_show'] ) : ?>
<p class="eael-product-list-quick-view-button eael-m-0">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars( json_encode( $woo_product_list_loop['quick_view_setting'] ), ENT_QUOTES ); ?>" class="open-popup-link">
<?php esc_html_e( $woo_product_list['quick_view_text'], 'essential-addons-for-elementor-lite' ); ?>
</a>
</p>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,148 @@
<?php
/**
* Template Name: Preset 2
*/
use Essential_Addons_Elementor\Elements\Woo_Product_List;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( empty( $woo_product_list ) ) {
$woo_product_list = Woo_Product_List::get_woo_product_list_settings( $settings );
}
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
$woo_product_list_loop = Woo_Product_List::get_woo_product_list_loop_settings( $product, $settings, $woo_product_list ); // static method as the template is used by read more feature too
?>
<div <?php post_class( 'product' ); ?>>
<div class="eael-product-list-item <?php echo esc_attr( $woo_product_list['image_alignment'] ); ?>">
<?php if( 'badge-preset-2' === $woo_product_list['badge_preset'] ) : ?>
<?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?>
<?php endif; ?>
<div class="eael-product-list-image-wrap">
<?php if( 'badge-preset-2' !== $woo_product_list['badge_preset'] ) : ?>
<?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?>
<?php endif; ?>
<?php if ( $woo_product_list['image_clickable'] ) : ?>
<a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="woocommerce-LoopProduct-link woocommerce-loop-product__link" >
<?php endif; ?>
<?php echo wp_kses_post( $product->get_image( $woo_product_list['image_size'], ['loading' => 'eager'] ) ); ?>
<?php if ( $woo_product_list['image_clickable'] ) : ?>
</a>
<?php endif; ?>
<?php if ( $woo_product_list['button_position_on_hover'] ) : ?>
<ul class="eael-product-list-buttons-on-hover">
<?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?>
<li class="eael-product-list-add-to-cart-button eael-m-0">
<?php woocommerce_template_loop_add_to_cart(); ?>
</li>
<?php endif; ?>
<?php if ( $woo_product_list['quick_view_button_show'] ) : ?>
<li class="eael-product-list-quick-view-button eael-m-0">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars( json_encode( $woo_product_list_loop['quick_view_setting'] ), ENT_QUOTES ); ?>" class="open-popup-link"><i class="fas fa-eye"></i></a>
</li>
<?php endif; ?>
<?php if ( $woo_product_list['link_button_show'] ) : ?>
<li class="eael-product-list-link-button eael-m-0">
<a href="<?php echo esc_url( $product->get_permalink() ); ?>"><i class="fas fa-link"></i></a>
</li>
<?php endif; ?>
</ul>
<?php endif; ?>
</div>
<div class="eael-product-list-content-wrap">
<?php
if ( 'after-title' === $woo_product_list['content_header_position'] ) :
Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product );
endif;
?>
<div class="eael-product-list-content-header <?php echo esc_attr( $woo_product_list_loop['direction_rtl_class'] ) ?>" >
<?php if ( $woo_product_list['rating_show'] ) : ?>
<div class="eael-product-list-rating">
<?php echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) ); ?>
<?php if ( $woo_product_list['review_count_show'] && $woo_product_list_loop['review_count'] > 0 ) : ?>
<a href="<?php echo esc_url( get_permalink() ) ?>#reviews" class="woocommerce-review-link eael-product-list-review-count" rel="nofollow">(<?php printf( '%s', __( $woo_product_list_loop['review_count'], 'essential-addons-for-elementor-lite' ) ); ?>)</a>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="eael-product-list-notice eael-product-list-notice-category">
<?php if ( $woo_product_list['category_show'] && $woo_product_list_loop['has_terms'] ) : ?>
<p>
<i class="fas fa-box"></i>
<?php echo esc_html( Woo_Product_List::eael_get_product_category_name( $woo_product_list_loop['terms'] ) ); ?>
</p>
<?php endif; ?>
</div>
</div>
<div class="eael-product-list-content-body">
<?php
if ( 'before-title' === $woo_product_list['content_header_position'] ) :
Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product );
endif;
?>
<?php if ( $woo_product_list['excerpt_show'] ) : ?>
<div class="eael-product-list-excerpt">
<?php echo wp_trim_words( strip_shortcodes( get_the_excerpt() ), $woo_product_list['excerpt_words_count'], $woo_product_list['excerpt_expanison_indicator'] ); ?>
</div>
<?php endif; ?>
<?php if ( $woo_product_list['price_show'] ) : ?>
<h3 class="eael-product-list-price">
<?php echo wp_kses_post( $product->get_price_html() ); ?>
</h3>
<?php endif; ?>
</div>
<div class="eael-product-list-content-footer">
<?php if ( $woo_product_list['total_sold_show'] ) : ?>
<div class="eael-product-list-progress">
<div class="eael-product-list-progress-info">
<h4 class="eael-product-list-progress-count"><?php esc_html_e( $woo_product_list['total_sold_text'], 'essential-addons-for-elementor-lite' ); ?> <span><?php echo esc_html( $woo_product_list_loop['total_sales_count'] ); ?></span></h4>
<?php if( $product->managing_stock() && $woo_product_list['total_sold_remaining_show'] ) : ?>
<h4 class="eael-product-list-progress-remaining"><?php esc_html_e( $woo_product_list['total_sold_remaining_text'], 'essential-addons-for-elementor-lite' ); ?> <span><?php echo esc_html( $woo_product_list_loop['stock_quantity_count'] ); ?></span></h4>
<?php endif; ?>
</div>
<div class="eael-product-list-progress-bar-outer">
<div style="width: <?php echo esc_attr( $woo_product_list_loop['total_sold_progress_percentage'] ); ?>%;" class="eael-product-list-progress-bar-inner"></div>
</div>
</div>
<?php endif; ?>
<?php if ( $woo_product_list['button_position_static'] ) : ?>
<div class="eael-product-list-buttons">
<?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?>
<p class="eael-product-list-add-to-cart-button eael-m-0"><?php woocommerce_template_loop_add_to_cart(); ?></p>
<?php endif; ?>
<?php if ( $woo_product_list['quick_view_button_show'] ) : ?>
<p class="eael-product-list-quick-view-button eael-m-0">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars( json_encode( $woo_product_list_loop['quick_view_setting'] ), ENT_QUOTES ); ?>" class="open-popup-link">
<?php esc_html_e( $woo_product_list['quick_view_text'], 'essential-addons-for-elementor-lite' ); ?>
</a>
</p>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,136 @@
<?php
/**
* Template Name: Preset 3
*/
use Essential_Addons_Elementor\Elements\Woo_Product_List;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( empty( $woo_product_list ) ) {
$woo_product_list = Woo_Product_List::get_woo_product_list_settings( $settings );
}
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
$woo_product_list_loop = Woo_Product_List::get_woo_product_list_loop_settings( $product, $settings, $woo_product_list ); // static method as the template is used by read more feature too
?>
<div <?php post_class( 'product' ); ?>>
<div class="eael-product-list-item <?php echo esc_attr( $woo_product_list['image_alignment'] ); ?>">
<?php if( 'badge-preset-2' === $woo_product_list['badge_preset'] ) : ?>
<?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?>
<?php endif; ?>
<div class="eael-product-list-image-wrap">
<?php if( 'badge-preset-2' !== $woo_product_list['badge_preset'] ) : ?>
<?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?>
<?php endif; ?>
<?php if ( $woo_product_list['image_clickable'] ) : ?>
<a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="woocommerce-LoopProduct-link woocommerce-loop-product__link" >
<?php endif; ?>
<?php echo wp_kses_post( $product->get_image( $woo_product_list['image_size'], ['loading' => 'eager'] ) ); ?>
<?php if ( $woo_product_list['image_clickable'] ) : ?>
</a>
<?php endif; ?>
<?php if ( $woo_product_list['button_position_on_hover'] ) : ?>
<ul class="eael-product-list-buttons-on-hover">
<?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?>
<li class="eael-product-list-add-to-cart-button eael-m-0">
<?php woocommerce_template_loop_add_to_cart(); ?>
</li>
<?php endif; ?>
<?php if ( $woo_product_list['quick_view_button_show'] ) : ?>
<li class="eael-product-list-quick-view-button eael-m-0">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars( json_encode( $woo_product_list_loop['quick_view_setting'] ), ENT_QUOTES ); ?>" class="open-popup-link"><i class="fas fa-eye"></i></a>
</li>
<?php endif; ?>
<?php if ( $woo_product_list['link_button_show'] ) : ?>
<li class="eael-product-list-link-button eael-m-0">
<a href="<?php echo esc_url( $product->get_permalink() ); ?>"><i class="fas fa-link"></i></a>
</li>
<?php endif; ?>
</ul>
<?php endif; ?>
</div>
<div class="eael-product-list-content-wrap">
<?php
if ( 'after-title' === $woo_product_list['content_header_position'] ) :
Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product );
endif;
?>
<div class="eael-product-list-content-header <?php echo esc_attr( $woo_product_list_loop['direction_rtl_class'] ) ?>" >
<?php if ( $woo_product_list['rating_show'] ) : ?>
<div class="eael-product-list-rating">
<?php echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) ); ?>
<?php if ( $woo_product_list['review_count_show'] && $woo_product_list_loop['review_count'] > 0 ) : ?>
<a href="<?php echo esc_url( get_permalink() ) ?>#reviews" class="woocommerce-review-link eael-product-list-review-count" rel="nofollow">(<?php printf( '%s', __( $woo_product_list_loop['review_count'], 'essential-addons-for-elementor-lite' ) ); ?>)</a>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<div class="eael-product-list-content-body">
<?php
if ( 'before-title' === $woo_product_list['content_header_position'] ) :
Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product );
endif;
?>
<?php if ( $woo_product_list['excerpt_show'] ) : ?>
<div class="eael-product-list-excerpt">
<?php echo wp_trim_words( strip_shortcodes( get_the_excerpt() ), $woo_product_list['excerpt_words_count'], $woo_product_list['excerpt_expanison_indicator'] ); ?>
</div>
<?php endif; ?>
<?php if ( $woo_product_list['price_show'] ) : ?>
<h3 class="eael-product-list-price">
<?php echo wp_kses_post( $product->get_price_html() ); ?>
</h3>
<?php endif; ?>
</div>
<div class="eael-product-list-content-footer">
<?php if ( $woo_product_list['button_position_static'] ) : ?>
<div class="eael-product-list-buttons">
<?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?>
<p class="eael-product-list-add-to-cart-button eael-m-0"><?php woocommerce_template_loop_add_to_cart(); ?></p>
<?php endif; ?>
<?php if ( $woo_product_list['total_sold_show'] ) : ?>
<div class="eael-product-list-progress">
<div class="eael-product-list-progress-info">
<h4 class="eael-product-list-progress-count"><?php esc_html_e( $woo_product_list['total_sold_text'], 'essential-addons-for-elementor-lite' ); ?> <span><?php echo esc_html( $woo_product_list_loop['total_sales_count'] ); ?></span> <?php _e('Item', 'essential-addons-for-elementor-lite'); ?></h4>
</div>
<div class="eael-product-list-progress-bar-outer">
<div style="width: <?php echo esc_attr( $woo_product_list_loop['total_sold_progress_percentage'] ); ?>%;" class="eael-product-list-progress-bar-inner"></div>
</div>
</div>
<?php endif; ?>
<div class="eael-product-list-notice eael-product-list-notice-shiping-free">
<?php if ( $woo_product_list['category_show'] && $woo_product_list_loop['has_terms'] ) : ?>
<p>
<i class="fas fa-box"></i>
<?php echo esc_html( Woo_Product_List::eael_get_product_category_name( $woo_product_list_loop['terms'] ) ); ?>
</p>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,712 @@
<?php
namespace Essential_Addons_Elementor\Template\Woocommerce\Cart;
use Elementor\Icons_Manager;
use \Essential_Addons_Elementor\Classes\Helper;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
trait Woo_Cart_Helper {
public static $setting_data = [];
public static function ea_get_woo_cart_settings() {
return self::$setting_data;
}
public static function ea_set_woo_cart_settings( $settings ) {
self::$setting_data = $settings;
}
/**
* Added all actions
*/
public function ea_woo_cart_add_actions( $settings ) {
// set ea cart controller settings
self::ea_set_woo_cart_settings( $settings );
}
public function ea_cart_render() {
$settings = self::ea_get_woo_cart_settings();
Woo_Cart_Shortcode::output( [], $settings );
}
public static function woo_cart_style_one( $settings ) { ?>
<form class="woocommerce-cart-form eael-woo-cart-form woocommerce" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
<?php do_action( 'woocommerce_before_cart_table' ); ?>
<div class="eael-cart-clear-btn mt10">
<?php if ( ! empty( $settings['eael_woo_cart_components_cart_clear_button'] ) && $settings['eael_woo_cart_components_cart_clear_button'] === 'yes' ) {
$clear_text = apply_filters( 'eael_woo_cart_clear_button_text', $settings['eael_woo_cart_components_cart_clear_button_text'] );
echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" class="button" title="' . esc_attr( $clear_text ) . '">' . esc_html( $clear_text ) . '</a>';
}
?>
</div>
<div class="eael-woo-cart-table-warp">
<table class="shop_table cart woocommerce-cart-form__contents eael-woo-cart-table">
<thead>
<tr>
<?php
if ( ! empty( $settings['table_items'] ) && is_array( $settings['table_items'] ) ) {
foreach ( $settings['table_items'] as $column_data ) {
$item_class = "elementor-repeater-item-{$column_data['_id']}";
?>
<th class="<?php echo esc_attr( "product-{$column_data['column_type']} {$item_class}" ); ?>">
<?php
$title = apply_filters( "eael_woo_cart_table_{$column_data['column_type']}_title", $column_data['column_heading_title'] );
echo esc_html( $title );
?>
</th>
<?php
}
}
?>
</tr>
</thead>
<tbody>
<?php
do_action( 'woocommerce_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0
&& apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key )
) {
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink',
$_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item,
$cart_item_key );
?>
<tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class',
'cart_item', $cart_item, $cart_item_key ) ); ?>">
<?php
if ( ! empty( $settings['table_items'] ) && is_array( $settings['table_items'] ) ) {
foreach ( $settings['table_items'] as $column_data ) {
$item_class = "elementor-repeater-item-{$column_data['_id']}";
switch ( $column_data['column_type'] ) {
case 'remove': ?>
<td class="product-remove <?php echo esc_attr( $item_class ); ?>">
<?php
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'woocommerce_cart_item_remove_link',
sprintf(
'<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">%s</a>',
esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
esc_html__( 'Remove this item', 'essential-addons-for-elementor-lite' ),
esc_attr( $product_id ),
esc_attr( $_product->get_sku() ),
Helper::get_render_icon( $column_data['item_remove_icon'], [ 'aria-hidden' => 'true' ] )
),
$cart_item_key
);
?>
</td>
<?php
break;
case 'thumbnail': ?>
<td class="product-thumbnail <?php echo esc_attr( $item_class ); ?>">
<?php
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
if ( ! $product_permalink ) {
echo $thumbnail; // PHPCS: XSS ok.
} else {
printf( '<a href="%s">%s</a>', esc_url( $product_permalink ),
$thumbnail ); // PHPCS: XSS ok.
}
?>
</td>
<?php
break;
case 'name': ?>
<td class="product-name <?php echo esc_attr( $item_class ); ?>">
<?php
if ( ! $product_permalink ) {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name',
$_product->get_name(), $cart_item, $cart_item_key )
. '&nbsp;' );
} else {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name',
sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ),
$_product->get_name() ), $cart_item, $cart_item_key ) );
}
do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );
// Meta data.
echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok.
// Backorder notification.
if ( $_product->backorders_require_notification()
&& $_product->is_on_backorder( $cart_item['quantity'] )
) {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification',
'<p class="backorder_notification">'
. esc_html__( 'Available on backorder', 'essential-addons-for-elementor-lite' )
. '</p>', $product_id ) );
}
?>
</td>
<?php
break;
case 'price': ?>
<td class="product-price <?php echo esc_attr( $item_class ); ?>">
<?php
echo apply_filters( 'woocommerce_cart_item_price',
WC()->cart->get_product_price( $_product ), $cart_item,
$cart_item_key ); // PHPCS: XSS ok.
?>
</td>
<?php
break;
case 'quantity': ?>
<td class="product-quantity <?php echo esc_attr( $item_class ); ?>">
<?php
if ( $_product->is_sold_individually() ) {
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
} else {
$product_quantity = woocommerce_quantity_input(
[
'input_name' => "cart[{$cart_item_key}][qty]",
'input_value' => $cart_item['quantity'],
'max_value' => $_product->get_max_purchase_quantity(),
'min_value' => '0',
'product_name' => $_product->get_name(),
],
$_product,
false
);
}
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity,
$cart_item_key, $cart_item ); // PHPCS: XSS ok.
?>
</td>
<?php
break;
case 'subtotal': ?>
<td class="product-subtotal <?php echo esc_attr( $item_class ); ?>">
<?php
echo apply_filters( 'woocommerce_cart_item_subtotal',
WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ),
$cart_item,
$cart_item_key ); // PHPCS: XSS ok.
?>
</td>
<?php
break;
}
}
}
?>
</tr>
<?php
}
}
do_action( 'woocommerce_cart_contents' );
do_action( 'woocommerce_after_cart_contents' ); ?>
</tbody>
</table>
</div>
<?php
do_action( 'woocommerce_after_cart_table' );
self::woo_cart_collaterals( $settings );
?>
</form>
<?php
}
public static function eael_woo_cart_totals( $settings ) {
if ( ! empty( $settings['ea_woo_cart_layout'] ) ) {
?>
<div class="cart_totals <?php echo ( WC()->customer->has_calculated_shipping() ) ? 'calculated_shipping' : ''; ?>">
<?php
do_action( 'woocommerce_before_cart_totals' );
if ( $settings['eael_woo_cart_components_cart_totals_subtotal'] === 'yes' || $settings['eael_woo_cart_components_cart_totals_coupon'] === 'yes' ||
$settings['eael_woo_cart_components_cart_totals_shipping'] === 'yes' ||
( ! empty( WC()->cart->get_fees() ) && $settings['eael_woo_cart_components_cart_totals_fees'] === 'yes' ) ||
$settings['eael_woo_cart_components_cart_totals_tax'] === 'yes' || $settings['eael_woo_cart_components_cart_totals_total'] === 'yes' ) {
?>
<table class="shop_table shop_table_responsive">
<?php if ( $settings['eael_woo_cart_components_cart_totals_subtotal'] === 'yes' ) {
$subtotal_label = apply_filters( 'eael_woo_cart_totals_subtotal_label', esc_html__( 'Subtotal', 'essential-addons-for-elementor-lite' ) );
?>
<tr class="cart-subtotal">
<th><?php echo esc_html( $subtotal_label ); ?></th>
<td data-title="<?php echo esc_attr( $subtotal_label ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
<?php } ?>
<?php
if ( $settings['eael_woo_cart_components_cart_totals_coupon'] === 'yes' ) {
foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td data-title="<?php echo esc_attr( wc_cart_totals_coupon_label( $coupon, false ) ); ?>"><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php
endforeach;
}
?>
<?php
if ( $settings['eael_woo_cart_components_cart_totals_shipping'] === 'yes' ) {
if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
<?php do_action( 'woocommerce_cart_totals_before_shipping' ); ?>
<?php wc_cart_totals_shipping_html(); ?>
<?php do_action( 'woocommerce_cart_totals_after_shipping' ); ?>
<?php elseif ( WC()->cart->needs_shipping() && 'yes' === get_option( 'woocommerce_enable_shipping_calc' ) ) :
$shipping_label = apply_filters( 'eael_woo_cart_totals_shipping_label', esc_html__( 'Shipping', 'essential-addons-for-elementor-lite' ) );
?>
<tr class="shipping">
<th><?php echo esc_html( $shipping_label ); ?></th>
<td data-title="<?php echo esc_attr( $shipping_label ); ?>"><?php woocommerce_shipping_calculator(); ?></td>
</tr>
<?php
endif;
} ?>
<?php
if ( $settings['eael_woo_cart_components_cart_totals_fees'] === 'yes' ) {
foreach ( WC()->cart->get_fees() as $fee ) : ?>
<tr class="fee">
<th><?php echo esc_html( $fee->name ); ?></th>
<td data-title="<?php echo esc_attr( $fee->name ); ?>"><?php wc_cart_totals_fee_html( $fee ); ?></td>
</tr>
<?php
endforeach;
} ?>
<?php
if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() && $settings['eael_woo_cart_components_cart_totals_tax'] === 'yes' ) {
$taxable_address = WC()->customer->get_taxable_address();
$estimated_text = '';
if ( WC()->customer->is_customer_outside_base() && ! WC()->customer->has_calculated_shipping() ) {
/* translators: %s location. */
$estimated_text = sprintf( ' <small>' . esc_html__( '(estimated for %s)', 'essential-addons-for-elementor-lite' ) . '</small>', WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ] );
}
if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) {
foreach ( WC()->cart->get_tax_totals() as $code => $tax ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
?>
<tr class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php echo esc_html( $tax->label ) . $estimated_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th>
<td data-title="<?php echo esc_attr( $tax->label ); ?>"><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
</tr>
<?php
}
} else {
?>
<tr class="tax-total">
<th><?php echo esc_html( WC()->countries->tax_or_vat() ) . $estimated_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th>
<td data-title="<?php echo esc_attr( WC()->countries->tax_or_vat() ); ?>"><?php wc_cart_totals_taxes_total_html(); ?></td>
</tr>
<?php
}
}
?>
<?php
do_action( 'woocommerce_cart_totals_before_order_total' );
if ( $settings['eael_woo_cart_components_cart_totals_total'] === 'yes' ) {
$total_label = apply_filters( 'eael_woo_cart_totals_total_label', esc_html__( 'Total', 'essential-addons-for-elementor-lite' ) );
?>
<tr class="order-total">
<th><?php echo esc_html( $total_label ); ?></th>
<td data-title="<?php echo esc_attr( $total_label ); ?>"><?php wc_cart_totals_order_total_html(); ?></td>
</tr>
<?php
}
do_action( 'woocommerce_cart_totals_after_order_total' );
?>
</table>
<?php
}
?>
<div class="wc-proceed-to-checkout">
<?php do_action( 'woocommerce_proceed_to_checkout', $settings ); ?>
</div>
<?php
do_action( 'woocommerce_after_cart_totals' ); ?>
</div>
<?php
} else {
woocommerce_cart_totals();
}
}
public function remove_woocommerce_cross_sell_display( $settings ) {
// Remove default 'woocommerce_cross_sell_display' callback from 'woocommerce_cart_collaterals'
remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
}
public static function eael_cart_button_proceed_to_checkout( $settings ) {
if ( ! empty( $settings['ea_woo_cart_layout'] ) ) {
$button_text = apply_filters( 'eael_woo_cart_checkout_button_text', $settings['eael_woo_cart_components_cart_checkout_button_text'] );
?>
<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="checkout-button button alt wc-forward">
<?php echo esc_html( $button_text ); ?>
</a>
<?php
} else {
woocommerce_button_proceed_to_checkout();
}
}
public static function woo_cart_style_two( $settings ) { ?>
<form class="woocommerce-cart-form eael-woo-cart-form woocommerce" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
<?php do_action( 'woocommerce_before_cart_table' ); ?>
<div class="eael-cart-clear-btn mt10">
<?php if ( ! empty( $settings['eael_woo_cart_components_cart_clear_button'] ) && $settings['eael_woo_cart_components_cart_clear_button'] === 'yes' ) {
$clear_text = apply_filters( 'eael_woo_cart_clear_button_text', $settings['eael_woo_cart_components_cart_clear_button_text'] );
echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" class="button" title="' . esc_attr( $clear_text ) . '">' . esc_html( $clear_text ) . '</a>';
}
?>
</div>
<div class="shop_table cart woocommerce-cart-form__contents eael-woo-cart-table">
<?php
$has_table_left_components = $settings['eael_woo_cart_table_components_thumbnail'] === 'yes' ? true : false;
$has_table_right_components = in_array( 'yes', [
$settings['eael_woo_cart_table_components_price'],
$settings['eael_woo_cart_table_components_qty'],
$settings['eael_woo_cart_table_components_subtotal'],
$settings['eael_woo_cart_table_components_remove']
] ) ? true : false;
if ( $has_table_left_components || $has_table_right_components ) {
?>
<div class="eael-woo-cart-thead">
<div class="eael-woo-cart-tr">
<?php if ( $has_table_left_components ) { ?>
<div class="eael-woo-cart-tr-left">
<div class="eael-woo-cart-td product-thumbnail">
<?php
$title = apply_filters( "eael_woo_cart_table_thumbnail_title", $settings['eael_woo_cart_table_components_thumbnail_title'] );
echo esc_html( $title );
?>
</div>
</div>
<?php
}
if ( $has_table_right_components ) { ?>
<div class="eael-woo-cart-tr-right">
<?php if ( $settings['eael_woo_cart_table_components_price'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-price">
<?php
$title = apply_filters( "eael_woo_cart_table_price_title", $settings['eael_woo_cart_table_components_price_title'] );
echo esc_html( $title );
?>
</div>
<?php
}
if ( $settings['eael_woo_cart_table_components_qty'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-quantity">
<?php
$title = apply_filters( "eael_woo_cart_table_quantity_title", $settings['eael_woo_cart_table_components_qty_title'] );
echo esc_html( $title );
?>
</div>
<?php
}
if ( $settings['eael_woo_cart_table_components_subtotal'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-subtotal">
<?php
$title = apply_filters( "eael_woo_cart_table_subtotal_title", $settings['eael_woo_cart_table_components_subtotal_title'] );
echo esc_html( $title );
?>
</div>
<?php
}
if ( $settings['eael_woo_cart_table_components_remove'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-remove"></div>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
<div class="eael-woo-cart-tbody">
<?php
do_action( 'woocommerce_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0
&& apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key )
) {
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink',
$_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item,
$cart_item_key );
?>
<div class="eael-woo-cart-tr woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class',
'cart_item', $cart_item, $cart_item_key ) ); ?>">
<?php if ( $has_table_left_components ) { ?>
<div class="eael-woo-cart-tr-left">
<div class="eael-woo-cart-td product-thumbnail">
<?php
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
if ( ! $product_permalink ) {
echo $thumbnail; // PHPCS: XSS ok.
} else {
printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); // PHPCS: XSS ok.
}
if ( $settings['eael_woo_cart_table_components_remove'] === 'yes' ) { ?>
<div class="eael-woo-cart-product-remove">
<?php
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'woocommerce_cart_item_remove_link',
sprintf(
'<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">%s</a>',
esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
esc_html__( 'Remove this item', 'essential-addons-for-elementor-lite' ),
esc_attr( $product_id ),
esc_attr( $_product->get_sku() ),
Helper::get_render_icon( $settings['eael_woo_cart_table_components_remove_icon'], [ 'aria-hidden' => 'true' ] )
),
$cart_item_key
);
?>
</div>
<?php }
?>
</div>
<?php if ( $settings['eael_woo_cart_table_components_name'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-name">
<?php
if ( ! $product_permalink ) {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . '&nbsp;' );
} else {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ),
$_product->get_name() ), $cart_item, $cart_item_key ) );
}
do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );
// Product SKU
if ( $settings['eael_woo_cart_table_components_sku'] === 'yes' && ! empty( $_product->get_sku() ) ) {
printf( '<p class="eael-woo-cart-sku">#%s</p>', $_product->get_sku() );
}
// Meta data.
echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok.
// Backorder notification.
if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification',
'<p class="backorder_notification">'
. esc_html__( 'Available on backorder', 'essential-addons-for-elementor-lite' )
. '</p>', $product_id ) );
}
?>
</div>
<?php } ?>
</div>
<?php
}
if ( $has_table_right_components ) { ?>
<div class="eael-woo-cart-tr-right">
<?php if ( $settings['eael_woo_cart_table_components_price'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-price">
<?php
echo apply_filters( 'woocommerce_cart_item_price',
WC()->cart->get_product_price( $_product ), $cart_item,
$cart_item_key ); // PHPCS: XSS ok.
?>
</div>
<?php
}
if ( $settings['eael_woo_cart_table_components_qty'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-quantity">
<?php
if ( $_product->is_sold_individually() ) {
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
} else {
$product_quantity = woocommerce_quantity_input(
[
'input_name' => "cart[{$cart_item_key}][qty]",
'input_value' => $cart_item['quantity'],
'max_value' => $_product->get_max_purchase_quantity(),
'min_value' => '0',
'product_name' => $_product->get_name(),
],
$_product,
false
);
}
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity,
$cart_item_key, $cart_item ); // PHPCS: XSS ok.
?>
</div>
<?php
}
if ( $settings['eael_woo_cart_table_components_subtotal'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-subtotal" data-title="<?php echo esc_html( $title ); ?>">
<?php
echo apply_filters( 'woocommerce_cart_item_subtotal',
WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ),
$cart_item,
$cart_item_key ); // PHPCS: XSS ok.
?>
</div>
<?php
}
if ( $settings['eael_woo_cart_table_components_remove'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-remove">
<?php
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'woocommerce_cart_item_remove_link',
sprintf(
'<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">%s</a>',
esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
esc_html__( 'Remove this item', 'essential-addons-for-elementor-lite' ),
esc_attr( $product_id ),
esc_attr( $_product->get_sku() ),
Helper::get_render_icon( $settings['eael_woo_cart_table_components_remove_icon'], [ 'aria-hidden' => 'true' ] )
),
$cart_item_key
);
?>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
<?php
}
}
do_action( 'woocommerce_cart_contents' );
do_action( 'woocommerce_after_cart_contents' ); ?>
</div>
<?php } ?>
</div>
<?php
do_action( 'woocommerce_after_cart_table' );
self::woo_cart_collaterals( $settings );
?>
</form>
<?php
}
public static function woo_cart_collaterals( $settings ) { ?>
<div class="eael-cart-coupon-and-collaterals">
<div class="eael-cart-coupon-wrapper">
<?php if ( wc_coupons_enabled() && $settings['eael_woo_cart_components_cart_coupon'] === 'yes' ) {
$button_text = apply_filters( 'eael_woo_cart_coupon_button_text', $settings['eael_woo_cart_components_cart_coupon_button_text'] );
$placeholder = apply_filters( 'eael_woo_cart_coupon_placeholder', $settings['eael_woo_cart_components_cart_coupon_placeholder'] );
$coupon_label = apply_filters( 'eael_woo_cart_coupon_label_text', esc_html__( 'Coupon:', 'essential-addons-for-elementor-lite' ) );
?>
<div class="coupon">
<label for="coupon_code" class="sr-only"><?php echo esc_html( $coupon_label ); ?></label>
<input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php echo esc_attr( $placeholder ); ?>"/>
<button type="submit" class="button" name="apply_coupon"
value="<?php echo esc_attr( $button_text ); ?>"><?php echo esc_html( $button_text ); ?></button>
<?php do_action( 'woocommerce_cart_coupon' ); ?>
</div>
<?php
}
if ( $settings['eael_woo_cart_components_continue_shopping'] === 'yes' ) {
$continue_shopping_text = apply_filters( 'eael_woo_cart_continue_shopping_text', $settings['eael_woo_cart_components_continue_shopping_text'] );
printf( '<a class="eael-woo-cart-back-to-shop" href="%s">%s %s</a>',
get_permalink( wc_get_page_id( 'shop' ) ),
Helper::get_render_icon( $settings['eael_woo_cart_components_continue_shopping_icon'], [ 'aria-hidden' => 'true' ] ),
esc_html( $continue_shopping_text )
);
}
?>
</div>
<?php do_action( 'woocommerce_before_cart_collaterals' ); ?>
<div class="cart-collaterals">
<div class="eael-cart-update-btn">
<?php if ( $settings['eael_woo_cart_components_cart_update_button'] === 'yes' ) {
$update_text = apply_filters( 'eael_woo_cart_update_button_text', $settings['eael_woo_cart_components_cart_update_button_text'] );
?>
<button type="submit" class="button" name="update_cart" value="<?php echo esc_attr( $update_text ); ?>"><?php echo esc_html( $update_text ); ?></button>
<?php
}
else if ( ! $settings['eael_woo_cart_components_cart_update_button'] && $settings['eael_woo_cart_auto_cart_update'] === 'yes' ){
echo '<button type="submit" class="button" name="update_cart" style="display:none;"></button>';
}
do_action( 'woocommerce_cart_actions' );
wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' );
?>
</div>
<?php
/**
* Cart collaterals hook.
*
* @hooked woocommerce_cross_sell_display
* @hooked woocommerce_cart_totals - 10
*/
do_action( 'eael_woocommerce_before_cart_collaterals', $settings );
if ( $settings['eael_woo_cart_components_cart_totals'] === 'yes' ) {
do_action( 'woocommerce_cart_collaterals', $settings );
} else {
?>
<div class="cart_totals">
<div class="wc-proceed-to-checkout">
<?php do_action( 'woocommerce_proceed_to_checkout', $settings ); ?>
</div>
</div>
<?php
}
?>
</div>
</div>
<?php
}
public function wc_empty_cart_message( $message ) {
$settings = self::ea_get_woo_cart_settings();
$empty_text = $settings['eael_woo_cart_components_empty_cart_text'];
return empty( $empty_text ) ? $message : esc_html( $empty_text );
}
}

View File

@@ -0,0 +1,91 @@
<?php
namespace Essential_Addons_Elementor\Template\Woocommerce\Cart;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( class_exists( '\WC_Shortcode_Cart' ) ) {
class Woo_Cart_Shortcode extends \WC_Shortcode_Cart {
use Woo_Cart_Helper;
/**
* Output the cart shortcode.
*
* @param array $atts Shortcode attributes.
*/
public static function output( $atts, $settings = [] ) {
if ( ! apply_filters( 'woocommerce_output_cart_shortcode_content', true ) ) {
return;
}
// Constants.
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
$atts = shortcode_atts( [], $atts, 'woocommerce_cart' );
$nonce_value = wc_get_var( $_REQUEST['woocommerce-shipping-calculator-nonce'],
wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine.
// Update Shipping. Nonce check uses new value and old value (woocommerce-cart). @todo remove in 4.0.
if ( ! empty( $_POST['calc_shipping'] )
&& ( wp_verify_nonce( $nonce_value, 'woocommerce-shipping-calculator' )
|| wp_verify_nonce( $nonce_value, 'woocommerce-cart' ) )
) { // WPCS: input var ok.
self::calculate_shipping();
// Also calc totals before we check items so subtotals etc are up to date.
WC()->cart->calculate_totals();
}
// Check cart items are valid.
do_action( 'woocommerce_check_cart_items' );
// Calc totals.
WC()->cart->calculate_totals();
$auto_update = $settings['eael_woo_cart_auto_cart_update'] === 'yes' ? 'eael-auto-update' : '';
if ( WC()->cart->is_empty() ) { ?>
<div class="eael-woo-cart-wrapper eael-woo-cart-empty <?php echo esc_attr( printf( '%s %s', "eael-woo-{$settings['ea_woo_cart_layout']}", $auto_update ) ); ?>">
<?php wc_get_template( 'cart/cart-empty.php' ); ?>
</div>
<?php
} else {
$style_two_wrapper_class = '';
if ( $settings['ea_woo_cart_layout'] === 'style-2' ) {
if ( $settings['eael_woo_cart_table_components_thumbnail'] === 'yes' ) {
$style_two_wrapper_class .= ' has-table-left-content';
}
if ( in_array( 'yes', [
$settings['eael_woo_cart_table_components_price'],
$settings['eael_woo_cart_table_components_qty'],
$settings['eael_woo_cart_table_components_subtotal'],
$settings['eael_woo_cart_table_components_remove']
] ) ) {
$style_two_wrapper_class .= ' has-table-right-content';
}
}
?>
<div class="eael-woo-cart-wrapper <?php echo esc_attr( sprintf( '%s %s %s', "eael-woo-{$settings['ea_woo_cart_layout']}", $auto_update, $style_two_wrapper_class ) ); ?>">
<?php
do_action( 'woocommerce_before_cart' );
switch ( $settings['ea_woo_cart_layout'] ) {
case 'default':
self::woo_cart_style_one( $settings );
break;
case 'style-2':
self::woo_cart_style_two( $settings );
break;
}
do_action( 'woocommerce_after_cart' );
?>
</div>
<?php
}
}
}
}

View File

@@ -0,0 +1,833 @@
<?php
namespace Essential_Addons_Elementor\Template\Woocommerce\Checkout;
use \Elementor\Icons_Manager;
use \Exception;
use \Essential_Addons_Elementor\Classes\Helper as CheckoutHelperCLass;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
trait Woo_Checkout_Helper {
public static $setting_data = [];
public static function ea_get_woo_checkout_settings(){
return self::$setting_data;
}
public static function ea_set_woo_checkout_settings($setting){
self::$setting_data = $setting;
}
/**
* Show the checkout.
*/
public static function ea_checkout($settings) {
// Show non-cart errors.
do_action( 'woocommerce_before_checkout_form_cart_notices' );
// Check cart has contents.
if ( WC()->cart->is_empty() && ! is_customize_preview() && apply_filters( 'woocommerce_checkout_redirect_empty_cart', true ) ) {
return;
}
// Check cart contents for errors.
do_action( 'woocommerce_check_cart_items' );
// Calc totals.
WC()->cart->calculate_totals();
// Get checkout object.
$checkout = WC()->checkout();
if ( empty( $_POST ) && wc_notice_count( 'error' ) > 0 ) { // WPCS: input var ok, CSRF ok.
wc_get_template( 'checkout/cart-errors.php', array( 'checkout' => $checkout ) );
wc_clear_notices();
} else {
$non_js_checkout = ! empty( $_POST['woocommerce_checkout_update_totals'] ); // WPCS: input var ok, CSRF ok.
if ( wc_notice_count( 'error' ) === 0 && $non_js_checkout ) {
wc_add_notice( __( 'The order totals have been updated. Please confirm your order by pressing the "Place order" button at the bottom of the page.', 'essential-addons-for-elementor-lite' ) );
}
if($settings['ea_woo_checkout_layout'] == 'default'){
echo self::render_default_template_($checkout, $settings);
}else {
do_action('eael_add_woo_checkout_pro_layout', $checkout, $settings);
}
}
}
/**
* Show the Order Received page.
*/
public static function ea_order_received( $order_id = 0 ) {
$order = false;
// Get the order.
$order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $order_id ) );
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( wp_unslash( $_GET['key'] ) ) ); // WPCS: input var ok, CSRF ok.
if ( $order_id > 0 ) {
$order = wc_get_order( $order_id );
if ( ! $order || ! hash_equals( $order->get_order_key(), $order_key ) ) {
$order = false;
}
}
// Empty awaiting payment session.
unset( WC()->session->order_awaiting_payment );
// In case order is created from admin, but paid by the actual customer, store the ip address of the payer
// when they visit the payment confirmation page.
if ( $order && $order->is_created_via( 'admin' ) ) {
$order->set_customer_ip_address( \WC_Geolocation::get_ip_address() );
$order->save();
}
// Empty current cart.
wc_empty_cart();
wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
}
/**
* Show the pay page.
*/
public static function ea_order_pay( $order_id ) {
do_action( 'before_woocommerce_pay' );
$order_id = absint( $order_id );
// Pay for existing order.
if ( isset( $_GET['pay_for_order'], $_GET['key'] ) && $order_id ) { // WPCS: input var ok, CSRF ok.
try {
$order_key = isset( $_GET['key'] ) ? wc_clean( wp_unslash( $_GET['key'] ) ) : ''; // WPCS: input var ok, CSRF ok.
$order = wc_get_order( $order_id );
$hold_stock_minutes = (int) get_option( 'woocommerce_hold_stock_minutes', 0 );
// Order or payment link is invalid.
if ( ! $order || $order->get_id() !== $order_id || ! hash_equals( $order->get_order_key(), $order_key ) ) {
throw new Exception( __( 'Sorry, this order is invalid and cannot be paid for.', 'essential-addons-for-elementor-lite' ) );
}
// Logged out customer does not have permission to pay for this order.
if ( ! current_user_can( 'pay_for_order', $order_id ) && ! is_user_logged_in() ) {
echo '<div class="woocommerce-info">' . esc_html__( 'Please log in to your account below to continue to the payment form.', 'essential-addons-for-elementor-lite' ) . '</div>';
woocommerce_login_form(
array(
'redirect' => $order->get_checkout_payment_url(),
)
);
return;
}
// Add notice if logged in customer is trying to pay for guest order.
if ( ! $order->get_user_id() && is_user_logged_in() ) {
// If order has does not have same billing email then current logged in user then show warning.
if ( $order->get_billing_email() !== wp_get_current_user()->user_email ) {
wc_print_notice( __( 'You are paying for a guest order. Please continue with payment only if you recognize this order.', 'essential-addons-for-elementor-lite' ), 'error' );
}
}
// Logged in customer trying to pay for someone else's order.
if ( ! current_user_can( 'pay_for_order', $order_id ) ) {
throw new Exception( __( 'This order cannot be paid for. Please contact us if you need assistance.', 'essential-addons-for-elementor-lite' ) );
}
// Does not need payment.
if ( ! $order->needs_payment() ) {
/* translators: %s: order status */
throw new Exception( sprintf( __( 'This order&rsquo;s status is &ldquo;%s&rdquo;&mdash;it cannot be paid for. Please contact us if you need assistance.', 'essential-addons-for-elementor-lite' ), wc_get_order_status_name( $order->get_status() ) ) );
}
// Ensure order items are still stocked if paying for a failed order. Pending orders do not need this check because stock is held.
if ( ! $order->has_status( wc_get_is_pending_statuses() ) ) {
$quantities = array();
foreach ( $order->get_items() as $item_key => $item ) {
if ( $item && is_callable( array( $item, 'get_product' ) ) ) {
$product = $item->get_product();
if ( ! $product ) {
continue;
}
$quantities[ $product->get_stock_managed_by_id() ] = isset( $quantities[ $product->get_stock_managed_by_id() ] ) ? $quantities[ $product->get_stock_managed_by_id() ] + $item->get_quantity() : $item->get_quantity();
}
}
foreach ( $order->get_items() as $item_key => $item ) {
if ( $item && is_callable( array( $item, 'get_product' ) ) ) {
$product = $item->get_product();
if ( ! $product ) {
continue;
}
if ( ! apply_filters( 'woocommerce_pay_order_product_in_stock', $product->is_in_stock(), $product, $order ) ) {
/* translators: %s: product name */
throw new Exception( sprintf( __( 'Sorry, "%s" is no longer in stock so this order cannot be paid for. We apologize for any inconvenience caused.', 'essential-addons-for-elementor-lite' ), $product->get_name() ) );
}
// We only need to check products managing stock, with a limited stock qty.
if ( ! $product->managing_stock() || $product->backorders_allowed() ) {
continue;
}
// Check stock based on all items in the cart and consider any held stock within pending orders.
$held_stock = ( $hold_stock_minutes > 0 ) ? wc_get_held_stock_quantity( $product, $order->get_id() ) : 0;
$required_stock = $quantities[ $product->get_stock_managed_by_id() ];
if ( ! apply_filters( 'woocommerce_pay_order_product_has_enough_stock', ( $product->get_stock_quantity() >= ( $held_stock + $required_stock ) ), $product, $order ) ) {
/* translators: 1: product name 2: quantity in stock */
throw new Exception( sprintf( __( 'Sorry, we do not have enough "%1$s" in stock to fulfill your order (%2$s available). We apologize for any inconvenience caused.', 'essential-addons-for-elementor-lite' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity() - $held_stock, $product ) ) );
}
}
}
}
WC()->customer->set_props(
array(
'billing_country' => $order->get_billing_country() ? $order->get_billing_country() : null,
'billing_state' => $order->get_billing_state() ? $order->get_billing_state() : null,
'billing_postcode' => $order->get_billing_postcode() ? $order->get_billing_postcode() : null,
)
);
WC()->customer->save();
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
if ( count( $available_gateways ) ) {
current( $available_gateways )->set_current();
}
wc_get_template(
'checkout/form-pay.php',
array(
'order' => $order,
'available_gateways' => $available_gateways,
'order_button_text' => apply_filters( 'woocommerce_pay_order_button_text', __( 'Pay for order', 'essential-addons-for-elementor-lite' ) ),
)
);
} catch ( Exception $e ) {
wc_print_notice( $e->getMessage(), 'error' );
}
} elseif ( $order_id ) {
// Pay for order after checkout step.
$order_key = isset( $_GET['key'] ) ? wc_clean( wp_unslash( $_GET['key'] ) ) : ''; // WPCS: input var ok, CSRF ok.
$order = wc_get_order( $order_id );
if ( $order && $order->get_id() === $order_id && hash_equals( $order->get_order_key(), $order_key ) ) {
if ( $order->needs_payment() ) {
wc_get_template( 'checkout/order-receipt.php', array( 'order' => $order ) );
} else {
/* translators: %s: order status */
wc_print_notice( sprintf( __( 'This order&rsquo;s status is &ldquo;%s&rdquo;&mdash;it cannot be paid for. Please contact us if you need assistance.', 'essential-addons-for-elementor-lite' ), wc_get_order_status_name( $order->get_status() ) ), 'error' );
}
} else {
wc_print_notice( __( 'Sorry, this order is invalid and cannot be paid for.', 'essential-addons-for-elementor-lite' ), 'error' );
}
} else {
wc_print_notice( __( 'Invalid order.', 'essential-addons-for-elementor-lite' ), 'error' );
}
do_action( 'after_woocommerce_pay' );
}
/**
* Show the coupon.
*/
public static function ea_coupon_template() {
$settings = self::ea_get_woo_checkout_settings();
if ( get_option( 'woocommerce_enable_coupons' ) === 'no' || $settings['ea_woo_checkout_coupon_hide'] === 'yes' ) {
return;
}
?>
<div class="woo-checkout-coupon">
<?php if( wc_coupons_enabled() ) { ?>
<div class="woocommerce-form-coupon-toggle">
<div class="ea-coupon-icon">
<?php Icons_Manager::render_icon( $settings['ea_woo_checkout_coupon_icon'], [ 'aria-hidden' => 'true' ] ); ?>
</div>
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_coupon_message', $settings['ea_woo_checkout_coupon_title'] . ' <a href="#" class="showcoupon">' . $settings['ea_woo_checkout_coupon_link_text'] . '</a>' ), 'notice' ); ?>
</div>
<form class="checkout_coupon woocommerce-form-coupon" method="post" style="display:none">
<p><?php esc_html_e( $settings['ea_woo_checkout_coupon_form_content'], 'essential-addons-for-elementor-lite' ); ?></p>
<p class="form-row form-row-first">
<input type="text" name="coupon_code" class="input-text" placeholder="<?php esc_attr_e( $settings['ea_woo_checkout_coupon_placeholder_text'], 'essential-addons-for-elementor-lite' ); ?>" id="coupon_code" value="" />
</p>
<p class="form-row form-row-last">
<button type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( $settings['ea_woo_checkout_coupon_button_text'], 'essential-addons-for-elementor-lite' ); ?>"><?php esc_html_e( $settings['ea_woo_checkout_coupon_button_text'], 'essential-addons-for-elementor-lite' ); ?></button>
</p>
<div class="clear"></div>
</form>
<?php } ?>
</div>
<?php }
/**
* Show the login.
*/
public static function ea_login_template(){
$settings = self::ea_get_woo_checkout_settings();
$class = '';
$status = true;
if('no' === get_option( 'woocommerce_enable_checkout_login_reminder')){
return '';
}elseif(\Elementor\Plugin::$instance->editor->is_edit_mode() && 'yes' === $settings['ea_section_woo_login_show']){
$class = 'woo-checkout-login-editor';
}elseif(!is_user_logged_in()){
$class = 'eael-woo-checkout-login-page';
}else{
return '';
}
ob_start();
?>
<div class="woo-checkout-login <?php echo $class; ?>">
<div class="woocommerce-form-login-toggle">
<div class="ea-login-icon">
<?php Icons_Manager::render_icon( $settings['ea_woo_checkout_login_icon'], [ 'aria-hidden' => 'true' ] ); ?>
</div>
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_login_message', $settings['ea_woo_checkout_login_title'] ) . ' <a href="#" class="showlogin">' . $settings['ea_woo_checkout_login_link_text'] . '</a>', 'notice' ); ?>
</div>
<?php
$message = CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_login_message']);
$redirect = wc_get_checkout_url();
$hidden = true;
?>
<form class="woocommerce-form woocommerce-form-login login" method="post" <?php echo ( $hidden ) ? 'style="display:none;"' : ''; ?>>
<?php do_action( 'woocommerce_login_form_start' ); ?>
<?php echo ( $message ) ? wpautop( wptexturize( $message ) ) : ''; // @codingStandardsIgnoreLine ?>
<p class="form-row form-row-first">
<label for="username"><?php esc_html_e( 'Username or email', 'essential-addons-for-elementor-lite' ); ?>&nbsp;<span class="required">*</span></label>
<input type="text" class="input-text" name="username" id="username" autocomplete="username" />
</p>
<p class="form-row form-row-last">
<label for="password"><?php esc_html_e( 'Password', 'essential-addons-for-elementor-lite' ); ?>&nbsp;<span class="required">*</span></label>
<input class="input-text" type="password" name="password" id="password" autocomplete="current-password" />
</p>
<div class="clear"></div>
<?php do_action( 'woocommerce_login_form' ); ?>
<p class="form-row">
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox woocommerce-form-login__rememberme">
<input class="woocommerce-form__input woocommerce-form__input-checkbox" name="rememberme" type="checkbox" id="rememberme" value="forever" /> <span><?php esc_html_e( 'Remember me', 'essential-addons-for-elementor-lite' ); ?></span>
</label>
<?php wp_nonce_field( 'woocommerce-login', 'woocommerce-login-nonce' ); ?>
<input type="hidden" name="redirect" value="<?php echo esc_url( $redirect ); ?>" />
<button type="submit" class="woocommerce-button button woocommerce-form-login__submit" name="login" value="<?php esc_attr_e( 'Login', 'essential-addons-for-elementor-lite' ); ?>"><?php esc_html_e( 'Login', 'essential-addons-for-elementor-lite' ); ?></button>
</p>
<p class="lost_password">
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php esc_html_e( 'Lost your password?', 'essential-addons-for-elementor-lite' ); ?></a>
</p>
<div class="clear"></div>
<?php do_action( 'woocommerce_login_form_end' ); ?>
</form>
</div>
<?php
$content = ob_get_clean();
if($status){
echo $content;
}
}
/**
* Show the login.
*/
public static function checkout_order_review_template() {
$settings = self::ea_get_woo_checkout_settings();
?>
<?php do_action('woocommerce_checkout_before_order_review_heading'); ?>
<h2 id="order_review_heading" class="woo-checkout-section-title">
<?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_order_details_title']); ?>
</h2>
<?php do_action('woocommerce_checkout_before_order_review'); ?>
<div class="ea-woo-checkout-order-review">
<?php self::checkout_order_review_default($settings); ?>
</div>
<?php do_action('woocommerce_checkout_after_order_review'); ?>
<?php }
public function remove_woocommerce_display_recurring_totals( $settings ){
remove_action('woocommerce_review_order_after_order_total', array( 'WC_Subscriptions_Cart', 'display_recurring_totals' ), 10);
}
/**
* Show the order review.
*/
public static function checkout_order_review_default($settings) {
WC()->cart->calculate_totals();
?>
<div class="ea-checkout-review-order-table">
<ul class="ea-order-review-table">
<?php
if( $settings['ea_woo_checkout_layout'] == 'default' ) { ?>
<li class="table-header">
<div class="table-col-1"><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_product_text']); ?></div>
<div class="table-col-2"><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_quantity_text']); ?></div>
<div class="table-col-3"><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_price_text']); ?></div>
</li>
<?php }
?>
<?php
do_action( 'woocommerce_review_order_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
?>
<li class="table-row <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
<div class="table-col-1 product-thum-name">
<div class="product-thumbnail">
<?php
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
echo $thumbnail; // PHPCS: XSS ok.
?>
</div>
<div class="product-name">
<?php $name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . '&nbsp;'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo CheckoutHelperCLass::eael_wp_kses( $name );
?>
<?php if( $settings['ea_woo_checkout_layout'] == 'split' || $settings['ea_woo_checkout_layout'] == 'multi-steps' ) {
if( !empty( $settings['ea_woo_checkout_cart_update_enable'] ) && 'yes' === $settings['ea_woo_checkout_cart_update_enable'] ) {
static::eael_checkout_cart_quantity_input_print( $_product, $cart_item_key, $cart_item );
}else {
echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '&times;&nbsp;%s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key );
}
} // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
</div>
<?php if( $settings['ea_woo_checkout_layout'] == 'default' ) { ?>
<div class="table-col-2 product-quantity">
<?php
if( !empty( $settings['ea_woo_checkout_cart_update_enable'] ) && 'yes' === $settings['ea_woo_checkout_cart_update_enable'] ) {
static::eael_checkout_cart_quantity_input_print( $_product, $cart_item_key, $cart_item );
} else {
echo apply_filters( 'woocommerce_checkout_cart_item_quantity', $cart_item['quantity'], $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</div>
<?php } ?>
<div class="table-col-3 product-total eael-checkout-cart-item-total">
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
</li>
<?php
}
}
do_action( 'woocommerce_review_order_after_cart_contents' );
?>
</ul>
<div class="ea-order-review-table-footer">
<!-- Show default text (from woocommerce) if change label control (ea_woo_checkout_table_header_text) is off -->
<?php $woo_checkout_order_details_change_label_settings = !empty($settings['ea_woo_checkout_table_header_text']) ? CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_header_text']) : ''; ?>
<?php
if($settings['ea_woo_checkout_shop_link'] == 'yes') { ?>
<div class="back-to-shop">
<a class="back-to-shopping" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>">
<?php //if($woo_checkout_order_details_change_label_settings == 'yes') : ?>
<!-- <i class="fas fa-long-arrow-alt-left"></i>--><?php //echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_shop_link_text']); ?>
<?php //else : ?>
<!-- <i class="fas fa-long-arrow-alt-left"></i>--><?php //esc_html_e( 'Continue Shopping', 'essential-addons-for-elementor-lite' ); ?>
<?php //endif; ?>
<i class="fas fa-long-arrow-alt-left"></i><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_shop_link_text']); ?>
</a>
</div>
<?php } ?>
<div class="footer-content">
<div class="cart-subtotal">
<?php if($woo_checkout_order_details_change_label_settings == 'yes') : ?>
<div><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_subtotal_text']); ?></div>
<?php else : ?>
<?php esc_html_e( 'Subtotal', 'essential-addons-for-elementor-lite' ); ?>
<?php endif; ?>
<div class="eael-checkout-cart-subtotal"><?php wc_cart_totals_subtotal_html(); ?></div>
</div>
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
<div class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<div><?php wc_cart_totals_coupon_label( $coupon ); ?></div>
<div><?php wc_cart_totals_coupon_html( $coupon ); ?></div>
</div>
<?php endforeach; ?>
<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
<?php do_action( 'woocommerce_review_order_before_shipping' ); ?>
<div class="shipping-area">
<?php
wc_cart_totals_shipping_html();
?>
</div>
<?php do_action( 'woocommerce_review_order_after_shipping' ); ?>
<?php endif; ?>
<?php do_action('eael_woo_checkout_before_cart_get_fees', WC()); ?>
<?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
<?php apply_filters('eael_woo_checkout_cart_fee', $fee); ?>
<div class="fee">
<div><?php echo esc_html( $fee->name ); ?></div>
<div><?php wc_cart_totals_fee_html( $fee ); ?></div>
</div>
<?php endforeach; ?>
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited ?>
<div class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<div><?php echo esc_html( $tax->label ); ?></div>
<div><?php echo wp_kses_post( $tax->formatted_amount ); ?></div>
</div>
<?php endforeach; ?>
<?php else : ?>
<div class="tax-total">
<div><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></div>
<div><?php wc_cart_totals_taxes_total_html(); ?></div>
</div>
<?php endif; ?>
<?php endif; ?>
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
<div class="order-total">
<?php if($woo_checkout_order_details_change_label_settings == 'yes') : ?>
<div><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_total_text']); ?></div>
<?php else : ?>
<?php esc_html_e( 'Total', 'essential-addons-for-elementor-lite' ); ?>
<?php endif; ?>
<div class="eael-checkout-cart-total"><?php wc_cart_totals_order_total_html(); ?></div>
</div>
<?php
if( class_exists('WC_Subscriptions_Cart') && (\WC_Subscriptions_Cart::cart_contains_subscription())) {
echo '<table class="recurring-wrapper">';
do_action( 'eael_display_recurring_total_total' );
echo '</table>';
}
?>
<?php do_action( 'woocommerce_review_order_after_order_total' ); ?>
</div>
</div>
</div>
<?php
}
/**
* Show the default layout.
*/
public static function render_default_template_($checkout, $settings) {
?>
<?php
// If checkout registration is disabled and not logged in, the user cannot checkout.
if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_required() && ! is_user_logged_in() ) {
echo esc_html( apply_filters( 'woocommerce_checkout_must_be_logged_in_message', __( 'You must be logged in to checkout.', 'essential-addons-for-elementor-lite' ) ) );
return;
}
?>
<?php do_action( 'woocommerce_before_checkout_form', $checkout ); ?>
<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
<?php if ( $checkout->get_checkout_fields() ) : ?>
<?php do_action( 'woocommerce_checkout_before_customer_details' ); ?>
<div class="col2-set" id="customer_details">
<div class="col-1">
<?php do_action( 'woocommerce_checkout_billing' ); ?>
</div>
<div class="col-2">
<?php do_action( 'woocommerce_checkout_shipping' ); ?>
</div>
</div>
<?php do_action( 'woocommerce_checkout_after_customer_details' ); ?>
<?php endif; ?>
<?php do_action( 'woocommerce_checkout_order_review' ); ?>
</form>
<?php
do_action('woocommerce_after_checkout_form', $checkout);
}
/**
* Output the billing form.
*/
public function ea_checkout_form_billing() {
// Get checkout object.
$checkout = WC()->checkout();
$settings = self::ea_get_woo_checkout_settings();
?>
<div class="woocommerce-billing-fields">
<?php if ( wc_ship_to_billing_address_only() && WC()->cart->needs_shipping() ) : ?>
<h3><?php esc_html_e( 'Billing &amp; Shipping', 'essential-addons-for-elementor-lite' ); ?></h3>
<?php else : ?>
<h3><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_billing_title']); ?></h3>
<?php endif; ?>
<?php do_action( 'woocommerce_before_checkout_billing_form', $checkout ); ?>
<div class="woocommerce-billing-fields__field-wrapper">
<?php
$fields = $checkout->get_checkout_fields( 'billing' );
foreach ( $fields as $key => $field ) {
woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
}
?>
</div>
<?php do_action( 'woocommerce_after_checkout_billing_form', $checkout ); ?>
</div>
<?php if ( ! is_user_logged_in() && $checkout->is_registration_enabled() ) : ?>
<div class="woocommerce-account-fields">
<?php if ( ! $checkout->is_registration_required() ) : ?>
<p class="form-row form-row-wide create-account">
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
<input class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" id="createaccount" <?php checked( ( true === $checkout->get_value( 'createaccount' ) || ( true === apply_filters( 'woocommerce_create_account_default_checked', false ) ) ), true ); ?> type="checkbox" name="createaccount" value="1" /> <span><?php esc_html_e( 'Create an account?', 'essential-addons-for-elementor-lite' ); ?></span>
</label>
</p>
<?php endif; ?>
<?php do_action( 'woocommerce_before_checkout_registration_form', $checkout ); ?>
<?php if ( $checkout->get_checkout_fields( 'account' ) ) : ?>
<div class="create-account">
<?php foreach ( $checkout->get_checkout_fields( 'account' ) as $key => $field ) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>
<div class="clear"></div>
</div>
<?php endif; ?>
<?php do_action( 'woocommerce_after_checkout_registration_form', $checkout ); ?>
</div>
<?php endif;
}
/**
* Output the shipping form.
*/
public function ea_checkout_form_shipping() {
// Get checkout object.
$checkout = WC()->checkout();
$settings = self::ea_get_woo_checkout_settings();
?>
<div class="woocommerce-shipping-fields">
<?php if ( true === WC()->cart->needs_shipping_address() ) : ?>
<h3 id="ship-to-different-address">
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
<input id="ship-to-different-address-checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" <?php checked( apply_filters( 'woocommerce_ship_to_different_address_checked', 'shipping' === get_option( 'woocommerce_ship_to_destination' ) ? 1 : 0 ), 1 ); ?> type="checkbox" name="ship_to_different_address" value="1" /> <span><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_shipping_title']); ?></span>
</label>
</h3>
<div class="shipping_address">
<?php do_action( 'woocommerce_before_checkout_shipping_form', $checkout ); ?>
<div class="woocommerce-shipping-fields__field-wrapper">
<?php
$fields = $checkout->get_checkout_fields( 'shipping' );
foreach ( $fields as $key => $field ) {
woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
}
?>
</div>
<?php do_action( 'woocommerce_after_checkout_shipping_form', $checkout ); ?>
</div>
<?php endif; ?>
</div>
<div class="woocommerce-additional-fields">
<?php do_action( 'woocommerce_before_order_notes', $checkout ); ?>
<?php if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' === get_option( 'woocommerce_enable_order_comments', 'yes' ) ) ) : ?>
<?php if ( ! WC()->cart->needs_shipping() || wc_ship_to_billing_address_only() ) : ?>
<h3><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_additional_info_title']); ?></h3>
<?php endif; ?>
<div class="woocommerce-additional-fields__field-wrapper">
<?php foreach ( $checkout->get_checkout_fields( 'order' ) as $key => $field ) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php do_action( 'woocommerce_after_order_notes', $checkout ); ?>
</div>
<?php }
/**
* Output the payment.
*/
public function ea_checkout_payment() {
if ( WC()->cart->needs_payment() ) {
$available_gateways = WC()->payment_gateways()->get_available_payment_gateways();
WC()->payment_gateways()->set_current_gateway( $available_gateways );
} else {
$available_gateways = array();
}
$settings = self::ea_get_woo_checkout_settings();
?>
<div class="woo-checkout-payment">
<?php do_action('eael_wc_multistep_checkout_after_shipping'); ?>
<h3 id="payment-title" class="woo-checkout-section-title">
<?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_payment_title']); ?>
</h3>
<?php wc_get_template(
'checkout/payment.php',
array(
'checkout' => WC()->checkout(),
'available_gateways' => $available_gateways,
'order_button_text' => apply_filters( 'woocommerce_order_button_text', CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_place_order_text']) ),
)
); ?>
</div>
<?php }
public function custom_shipping_package_name( $name ) {
if( ! empty( self::$setting_data[ 'ea_woo_checkout_table_shipping_text' ] ) ) {
$name = self::$setting_data['ea_woo_checkout_table_shipping_text'];
}
return $name;
}
/**
* Added all actions
*/
public function ea_woo_checkout_add_actions($settings) {
self::ea_set_woo_checkout_settings($settings);
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
if(!did_action('woocommerce_before_checkout_form')){
add_action( 'woocommerce_before_checkout_form', [ $this, 'ea_login_template' ], 10 );
add_action( 'woocommerce_before_checkout_form', [ $this, 'ea_coupon_template' ], 10 );
}
if( $settings['ea_woo_checkout_layout'] == 'default' ) {
if(!did_action('woocommerce_before_checkout_form')){
add_action( 'woocommerce_before_checkout_form', [ $this, 'checkout_order_review_template' ], 9 );
}
}
$wc_checkout_instance = WC()->checkout();
remove_action( 'woocommerce_checkout_billing', [ $wc_checkout_instance, 'checkout_form_billing' ] );
remove_action( 'woocommerce_checkout_shipping', [ $wc_checkout_instance, 'checkout_form_shipping' ] );
if(!did_action('woocommerce_checkout_billing')){
add_action( 'woocommerce_checkout_billing', [ $this, 'ea_checkout_form_billing' ], 10);
}
if(!did_action('woocommerce_checkout_shipping')){
add_action( 'woocommerce_checkout_shipping', [ $this, 'ea_checkout_form_shipping' ], 10 );
}
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
if(!did_action('woocommerce_checkout_order_review')){
add_action( 'woocommerce_checkout_order_review', [ $this, 'ea_checkout_payment' ], 20 );
}
remove_action('woocommerce_checkout_billing', [ $wc_checkout_instance, 'checkout_form_shipping' ]);
add_filter('woocommerce_shipping_package_name', [ $this, 'custom_shipping_package_name' ], 10, 3);
}
/**
* Print quantity input field
* @return void
*
* @since 5.1.4
*/
public static function eael_checkout_cart_quantity_input_print($_product, $cart_item_key, $cart_item){
if ( $_product->is_sold_individually() ) {
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
} else {
$product_quantity = woocommerce_quantity_input(
[
'input_name' => "cart[{$cart_item_key}][qty]",
'input_value' => $cart_item['quantity'],
'max_value' => $_product->get_max_purchase_quantity(),
'min_value' => '0',
'product_name' => $_product->get_name(),
'classes' => array('eael-checkout-cart-qty-input', 'input-text', 'qty', 'text'),
],
$_product,
false
);
}
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity,
$cart_item_key, $cart_item ); // PHPCS: XSS ok.
}
}

View File

@@ -0,0 +1 @@
<?php // Silence is golden