Sid Gifari File Manager
🏠 Root
/
home
/
ailwtbdh
/
lynchestinegroup.com
/
wp-content
/
themes
/
koncrete
/
inc
/
helper-traits
/
Editing: woo-trait.php
<?php /** * @author RadiusTheme * @since 1.0 * @version 1.0 */ namespace radiustheme\Koncrete; trait WooTrait { public static function get_top_category_name(){ global $product; $terms = wc_get_product_terms( $product->get_id(), 'product_cat', array( 'orderby' => 'parent', 'order' => 'DESC' ) ); if ( empty( $terms ) ) { return ''; } if ( $terms[0]->parent == 0 ) { $cat = $terms[0]; } else { $ancestors = get_ancestors( $terms[0]->term_id, 'product_cat', 'taxonomy' ); $cat_id = end( $ancestors ); $cat = get_term( $cat_id, 'product_cat' ); } return $cat->name; } public static function get_product_thumbnail( $product, $thumb_size = 'woocommerce_thumbnail' ) { $thumbnail = $product->get_image( $thumb_size, array(), false ); if ( !$thumbnail ) { $thumbnail = wc_placeholder_img( $thumb_size ); } return $thumbnail; } public static function print_add_to_wishlist_icon( $icon = true, $text = false ){ if ( !defined( 'YITH_WCWL' ) ) { return false; } if ( is_shop() && !RDTheme::$options['wc_wishlist_icon'] ) { return false; } if ( is_product() && !RDTheme::$options['wc_wishlist_icon'] ) { return false; } self::get_custom_template_part( 'wishlist-icon', compact( 'icon', 'text' ) ); } public static function get_custom_template_part( $template, $args = array() ){ $template = 'woocommerce/custom/template-parts/' . $template; self::get_template_part( $template, $args ); } public static function print_add_to_cart_icon( $icon = true, $text = true ){ global $product; $quantity = 1; $class = implode( ' ', array_filter( array( 'action-cart button', 'product_type_' . $product->get_type(), $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', $product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '', ) ) ); $html = ''; if ( $icon ) { $html .= '<i class="flaticon-shopping-cart"></i>'; } if ( $text ) { $html .= '<span>' . $product->add_to_cart_text() . '</span>'; } echo sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">' . $html . '</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 : 'action-cart' ) ); } public static function print_quickview_icon( $icon = true, $text = false ){ if ( !function_exists( 'YITH_WCQV_Frontend' ) ) { return false; } if ( is_shop() && !RDTheme::$options['wc_quickview_icon'] ) { return false; } if ( is_product() && !RDTheme::$options['wc_quickview_icon'] ) { return false; } global $product; $html = ''; if ( $icon ) { $html .= '<i class="flaticon-eye"></i>'; } if ( $text ) { $html .= '<span>' . esc_html__( 'QuickView', 'koncrete' ) . '</span>'; } ?> <a href="#" class="yith-wcqv-button" data-product_id="<?php echo esc_attr( $product->get_id() );?>" title="<?php esc_attr_e( 'QuickView', 'koncrete' ); ?>"><?php echo wp_kses_post( $html ); ?></a> <?php } }
Save
Cancel