| Server IP : 172.67.71.254 / Your IP : 216.73.216.4 Web Server : nginx/1.27.1 System : Linux in-5 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64 User : arabianexpress ( 1872) PHP Version : 8.0.30 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /storage/v9321/leapdubai/public_html/wp-content/plugins/printx-core/include/ |
Upload File : |
<?php
namespace TPCore;
defined('ABSPATH') || die();
class TP_El_Woocommerce
{
/**
* Instance
*
* @since 1.0.0
*
* @access private
* @static
*
* @var BdevsElement The single instance of the class.
*/
private static $_instance = null;
/**
* Instance
*
* Ensures only one instance of the class is loaded or can be loaded.
*
* @return BdevsElement An instance of the class.
* @since 1.0.0
*
* @access public
* @static
*
*/
public static function instance()
{
if (is_null(self::$_instance)) {
self::$_instance = new self();
}
return self::$_instance;
}
public static function tp_woo_add_to_cart( $args = array() ) {
global $product;
if ( $product ) {
$defaults = array(
'quantity' => 1,
'class' => implode(
' ',
array_filter(
array(
'cart-button icon-btn button tp-btn-cart',
'product_type_' . $product->get_type(),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
$product->supports( 'ajax_add_to_cart' ) && $product->is_purchasable() && $product->is_in_stock() ? 'ajax_add_to_cart' : '',
)
)
),
'attributes' => array(
'data-product_id' => $product->get_id(),
'data-product_sku' => $product->get_sku(),
'aria-label' => $product->add_to_cart_description(),
'rel' => 'nofollow',
),
);
$args = wp_parse_args( $args, $defaults );
if ( isset( $args['attributes']['aria-label'] ) ) {
$args['attributes']['aria-label'] = wp_strip_all_tags( $args['attributes']['aria-label'] );
}
}
// check product type
if( $product->is_type( 'simple' ) ){
$btntext = esc_html__("Add to Cart",'printx');
} elseif( $product->is_type( 'variable' ) ){
$btntext = esc_html__("Select Options",'printx');
} elseif( $product->is_type( 'external' ) ){
$btntext = esc_html__("Buy Now",'printx');
} elseif( $product->is_type( 'grouped' ) ){
$btntext = esc_html__("View Products",'printx');
}
else{
$btntext = "Add to Cart";
}
echo sprintf( '<a href="%s" data-quantity="%s" class="%s" %s>%s</a>',
esc_url( $product->add_to_cart_url() ),
esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
esc_attr( isset( $args['class'] ) ? $args['class'] : 'cart-button icon-btn button' ),
isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
'<span>
<svg width="16" height="14" viewBox="0 0 16 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.76 8.176H6.578C6.518 8.176 6.458 8.158 6.398 8.122C6.35 8.086 6.314 8.044 6.29 7.996L2.996 0.454C2.984 0.405999 2.948 0.363999 2.888 0.327999C2.84 0.291999 2.786 0.274 2.726 0.274H0.314C0.266 0.274 0.218 0.291999 0.17 0.327999C0.134 0.363999 0.116 0.411999 0.116 0.471999V1.066C0.116 1.114 0.134 1.162 0.17 1.21C0.218 1.246 0.266 1.264 0.314 1.264H2.078C2.138 1.264 2.192 1.282 2.24 1.318C2.3 1.354 2.336 1.396 2.348 1.444L5.66 8.986C5.672 9.034 5.702 9.076 5.75 9.112C5.81 9.148 5.87 9.166 5.93 9.166H13.76C13.82 9.166 13.868 9.148 13.904 9.112C13.94 9.064 13.958 9.016 13.958 8.968V8.374C13.958 8.314 13.94 8.266 13.904 8.23C13.868 8.194 13.82 8.176 13.76 8.176ZM7.532 10.156C7.124 10.156 6.776 10.3 6.488 10.588C6.2 10.876 6.056 11.224 6.056 11.632C6.056 12.04 6.2 12.394 6.488 12.694C6.776 12.982 7.124 13.126 7.532 13.126C7.94 13.126 8.288 12.982 8.576 12.694C8.876 12.394 9.026 12.04 9.026 11.632C9.026 11.224 8.882 10.876 8.594 10.588C8.306 10.3 7.952 10.156 7.532 10.156ZM12.482 10.156C12.074 10.156 11.72 10.3 11.42 10.588C11.132 10.876 10.988 11.224 10.988 11.632C10.988 12.04 11.132 12.394 11.42 12.694C11.72 12.982 12.074 13.126 12.482 13.126C12.89 13.126 13.238 12.982 13.526 12.694C13.814 12.406 13.958 12.058 13.958 11.65C13.958 11.23 13.814 10.876 13.526 10.588C13.238 10.3 12.89 10.156 12.482 10.156ZM15.74 2.254H5.264C5.204 2.254 5.162 2.272 5.138 2.308C5.126 2.344 5.126 2.386 5.138 2.434L5.39 3.064C5.414 3.112 5.45 3.154 5.498 3.19C5.558 3.226 5.612 3.244 5.66 3.244H15.344C15.392 3.244 15.44 3.226 15.488 3.19C15.548 3.154 15.59 3.112 15.614 3.064L15.866 2.434C15.878 2.386 15.872 2.344 15.848 2.308C15.836 2.272 15.8 2.254 15.74 2.254ZM14.156 6.196H6.848C6.8 6.196 6.758 6.214 6.722 6.25C6.698 6.286 6.698 6.328 6.722 6.376L6.974 7.006C6.986 7.054 7.016 7.096 7.064 7.132C7.124 7.168 7.184 7.186 7.244 7.186H13.76C13.82 7.186 13.874 7.168 13.922 7.132C13.982 7.096 14.018 7.054 14.03 7.006L14.282 6.376C14.306 6.328 14.3 6.286 14.264 6.25C14.24 6.214 14.204 6.196 14.156 6.196ZM14.948 4.216H6.056C6.008 4.216 5.966 4.234 5.93 4.27C5.906 4.306 5.906 4.348 5.93 4.396L6.182 5.026C6.194 5.074 6.224 5.116 6.272 5.152C6.332 5.188 6.392 5.206 6.452 5.206H14.552C14.612 5.206 14.666 5.188 14.714 5.152C14.774 5.116 14.81 5.074 14.822 5.026L15.074 4.396C15.098 4.348 15.092 4.306 15.056 4.27C15.032 4.234 14.996 4.216 14.948 4.216Z" fill="white"></path>
</svg>
</span>'.$btntext.' '
);
}
// quick view
public static function tp_woosq_button_html( $output , $prodid ) {
return $output = '<a href="#" class="icon-btn woosq-btn woosq-btn-' . esc_attr( $prodid ) . ' ' . get_option( 'woosq_button_class' ) . '" data-id="' . esc_attr( $prodid ) . '" data-effect="mfp-3d-unfold"><svg width="19" height="16" viewBox="0 0 19 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.49943 5.34978C8.23592 5.34978 7.20896 6.37595 7.20896 7.63732C7.20896 8.89774 8.23592 9.92296 9.49943 9.92296C10.7629 9.92296 11.7908 8.89774 11.7908 7.63732C11.7908 6.37595 10.7629 5.34978 9.49943 5.34978M9.49941 11.3456C7.45025 11.3456 5.78394 9.68213 5.78394 7.63738C5.78394 5.59169 7.45025 3.92725 9.49941 3.92725C11.5486 3.92725 13.2158 5.59169 13.2158 7.63738C13.2158 9.68213 11.5486 11.3456 9.49941 11.3456" fill="currentColor"/>
<path d="M1.49145 7.63683C3.25846 11.5338 6.23484 13.8507 9.50001 13.8517C12.7652 13.8507 15.7416 11.5338 17.5086 7.63683C15.7416 3.7408 12.7652 1.42386 9.50001 1.42291C6.23579 1.42386 3.25846 3.7408 1.49145 7.63683V7.63683ZM9.50173 15.2742H9.49793H9.49698C5.56775 15.2714 2.03943 12.5219 0.0577129 7.91746C-0.0192376 7.73822 -0.0192376 7.53526 0.0577129 7.35601C2.03943 2.75248 5.5687 0.00306822 9.49698 0.000223018C9.49888 -0.000725381 9.49888 -0.000725381 9.49983 0.000223018C9.50173 -0.000725381 9.50173 -0.000725381 9.50268 0.000223018C13.4319 0.00306822 16.9602 2.75248 18.942 7.35601C19.0199 7.53526 19.0199 7.73822 18.942 7.91746C16.9612 12.5219 13.4319 15.2714 9.50268 15.2742H9.50173Z" fill="currentColor"/>
</svg></a>';
}
public static function add_to_cart_button($product_id)
{
$product = wc_get_product($product_id);
if ($product) {
$defaults = array(
'quantity' => 1,
'class' => implode(' ', array_filter(array(
'',
'product_type_' . $product->get_type(),
$product->is_purchasable() && $product->is_in_stock() ? '' : '',
$product->supports('ajax_add_to_cart') ? 'ajax_add_to_cart' : ''
)))
);
extract($defaults);
return sprintf('<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s add_to_cart_button tp-btn"><i class="fal fa-shopping-cart"></i> Add To Cart</a>',
esc_url($product->add_to_cart_url()),
esc_attr(isset($quantity) ? $quantity : 1),
esc_attr($product->get_id()),
esc_attr($product->get_sku()),
esc_attr(isset($class) ? $class : 'button')
);
}
}
public static function quick_view_button($product_id) {
$product = wc_get_product($product_id);
$button = '';
if ( $product_id ) {
$button = '<a href="#" class="button yith-wcqv-button" data-product_id="' . esc_attr( $product_id ) . '" data-toggle="tooltip" data-placement="top" title="Quick View"><i class="fal fa-eye"></i></a>';
$button = apply_filters( 'yith_add_quick_view_button_html', $button, '', $product );
}
return $button;
}
public static function yith_wishlist($product_id)
{
$product = wc_get_product($product_id);
$cssclass = 'wishlist-rd';
$mar = 'tanzim-mar-top';
$id = $product->get_id();
$type = $product->get_type();
$link = get_site_url();
$img = '<img src="' . $link . '/wp-content/plugins/yith-woocommerce-wishlist/assets/images/wpspin_light.gif" class="ajax-loading tanzim_wi_loder" alt="loading" width="16" height="16" style="visibility:hidden">';
$markup = '';
if (BDEVSEL_WISHLIST_ACTIVED) {
$markup .= '<div class="yith-wcwl-add-to-wishlist ' . $mar . ' add-to-wishlist-' . $id . '">';
$markup .= '<div class="yith-wcwl-add-button wishlist show" style="display:block">';
$markup .= '<a href="' . $link . '/shop/?add_to_wishlist=' . $id . '" rel="nofollow" data-product-id="' . $id . '" data-product-type="' . $type . '" class="add_to_wishlist ' . $cssclass . '">';
$markup .= '<i class="fal fa-heart"></i></a>';
$markup .= $img;
$markup .= '</div>';
$markup .= '<div class="yith-wcwl-wishlistaddedbrowse wishlist hide" style="display:none;">';
$markup .= '<a href="' . $link . '/wishlist/view/" rel="nofollow" class=" ' . $cssclass . '"><i class="fal fa-heart"></i></a>';
$markup .= $img;
$markup .= '</div>';
$markup .= '<div class="yith-wcwl-wishlistexistsbrowse wishlist hide" style="display:none">';
$markup .= '<a href="' . $link . '/wishlist/view/" rel="nofollow" class=" ' . $cssclass . '"><i class="fal fa-heart"></i></a>';
$markup .= $img;
$markup .= '</div>';
$markup .= '<div style="clear:both"></div>';
$markup .= '<div class="yith-wcwl-wishlistaddresponse"></div>';
$markup .= '</div>';
}
return $markup;
}
// product_price
public static function product_price($product_id, $oldp = false)
{
$product = wc_get_product($product_id);
return $product->get_price_html();
}
// product_price_sale
public static function product_price_sale($product_id, $oldp = false)
{
$product = wc_get_product($product_id);
$woo_sale_tag = get_theme_mod('woo_sale_tag', 'Sale');
$price = $product->get_regular_price();
$old = '';
if ($product->get_sale_price() != '') {
if ($oldp) {
return '<span class="sale-text">' . $woo_sale_tag . '</span> ';
}
else{
'';
}
}
return false;
}
// bdevs_vc_product_thumb
public static function bdevs_vc_product_thumb($size = array(370, 425))
{
$markup = '';
global $post, $product, $woocommerce;
$attachment_ids = $product->get_gallery_image_ids();
$fea_image = array(get_post_thumbnail_id());
$attachment_ids = array_merge($fea_image, $attachment_ids);
$i = 1;
if (!empty($attachment_ids)) {
$markup .= '<a href="' . get_the_permalink() . '">';
foreach ($attachment_ids as $attachment_id) {
if ($i == 3) {
break;
}
$class = ($i == 1) ? 'front-img' : 'back-img';
$image_attributes = wp_get_attachment_image_src($attachment_id, $size);
if ($image_attributes[0] != '') {
$markup .= '<img class="' . $class . '" src="' . $image_attributes[0] . '" alt="' . esc_html__('image', 'bdevs-woocommerce') . '" >';
}
$i++;
}
$markup .= '</a>';
}
return $markup;
}
public static function bdevs_vc_loop_product_thumb()
{
$markup = '';
global $post, $product, $woocommerce;
$attachment_ids = $product->get_gallery_image_ids();
$fea_image = array(get_post_thumbnail_id());
$attachment_ids = array_merge($fea_image, $attachment_ids);
$i = 1;
if (!empty($attachment_ids)) {
$markup .= '<a href="' . get_the_permalink() . '">';
foreach ($attachment_ids as $attachment_id) {
if ($i == 3) {
break;
}
$class = ($i == 1) ? 'front-img' : 'back-img';
$image_attributes = wp_get_attachment_image_src($attachment_id, array(300, 300));
if ($image_attributes[0] != '') {
$markup .= '<img class="' . $class . '" src="' . $image_attributes[0] . '" alt="' . esc_html__('image', 'bdevs-woocommerce') . '" >';
}
$i++;
}
$markup .= '</a>';
}
return $markup;
}
public static function product_rating($product_id)
{
$product = wc_get_product($product_id);
$rating = $product->get_average_rating();
$review = 'Rating ' . $rating . ' out of 5';
$html = '';
$html .= '<div class="details-rating mb-10" title="' . $review . '">';
for ( $i = 0; $i <= 4; $i ++ ) {
if ( $i < floor( $rating ) ) {
$html .= '<i class="fas fa-star"></i>';
} else {
$html .= '<i class="far fa-star"></i>';
}
}
$html .= '</div>';
return $html;
}
function sectox_woo_rating() {
global $product;
$rating = $product->get_average_rating();
$review = 'Rating ' . $rating . ' out of 5';
$html = '';
$html .= '<div class="details-rating mb-10" title="' . $review . '">';
for ( $i = 0; $i <= 4; $i ++ ) {
if ( $i < floor( $rating ) ) {
$html .= '<i class="fas fa-star"></i>';
} else {
$html .= '<i class="far fa-star"></i>';
}
}
$html .= '<span>( ' . $rating . ' out of 5 )</span>';
$html .= '</div>';
print sectox_woo_rating_html( $html );
}
function sectox_woo_rating_html( $html ) {
return $html;
}
/**
* taxonomy category
*/
public static function product_get_terms($id, $tax)
{
$terms = get_the_terms(get_the_ID(), $tax);
$list = '';
if ($terms && !is_wp_error($terms)) :
$i = 1;
$cats_count = count($terms);
foreach ($terms as $term) {
$exatra = ($cats_count > $i) ? ', ' : '';
$list .= $term->name . $exatra;
$i++;
}
endif;
return trim($list, ',');
}
}
TP_El_Woocommerce::instance();