Skip to content

Commit

Permalink
Merge pull request #77 from codersaiful/2.8.3.3
Browse files Browse the repository at this point in the history
2.8.3.3
  • Loading branch information
codersaiful authored Feb 3, 2021
2 parents 29466e3 + 65bb46d commit 38d983e
Show file tree
Hide file tree
Showing 5 changed files with 353 additions and 66 deletions.
71 changes: 70 additions & 1 deletion admin/tabs/basics.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,54 @@
<?php
/**
add_filter( 'wp_nav_menu_items', 'add_mega_menu_items', 8888, 2);
function add_mega_menu_items( $items, $args ) {
// var_dump($args->menu);
if($args->menu == 627 ){ //&& $args->theme_location == 'primary-menu'
$categories=get_terms(
array(
'hide_empty' => true,
'taxonomy' => 'product_cat'
)
);
foreach ($categories as $category){
$active_class = false;
$act_id = get_queried_object_id();
if($category->parent == 0){
$child_items = '';
$parent_class = 'no_child';
$term_args = array(
'taxonomy' => 'product_cat',
'hide_empty' => true,
'parent' => $category->term_id,
);
$childs = get_terms( $term_args );
if( !empty( $childs ) ){
$parent_class = 'has_child';
$child_items .= '<ul class="sfl_childe_ul slf_parent_cat_id_' . $category->term_id . '" >';
foreach( $childs as $child ){
$active_class = $act_id == $child->term_id ? 'sfl_active_child_term sfl_active_menu': false;
$thumbnail_id = get_term_meta( $child->term_id, 'thumbnail_id', true );
$cat_image = wp_get_attachment_url( $thumbnail_id );
$cat_image = $cat_image ? '<img class="mega-menu-item-image" src="'. $cat_image .'">' : '';
$child_items .= '<li class="sfl_child_li slf_child_li_' . $child->term_id . ' ' . $active_class . '">'
. '<a href="'. get_category_link( $child->term_id ) .'">'
. $cat_image
. '<div>' . $child->name . '</div>'
. '</a>'
. '</li>';
}
$child_items .= '</ul>';
}
$active_class = $active_class || $act_id == $category->term_id ? 'sfl_active_term sfl_active_menu': false;
$items .= '<li class="sfl_parent_li parent_cat_id_' . $category->term_id . ' ' . $active_class . '"><a class="sfl_parent_class" href="'. get_category_link( $category->term_id ) .'">' . $category->name . '</a>' . $child_items . '</li>';
}
}
}
return $items;
}
*/
$meta_basics = get_post_meta( $post->ID, 'basics', true );
$data = isset( $meta_basics['data'] ) ? $meta_basics['data'] : false;

Expand Down Expand Up @@ -46,8 +96,27 @@
if( is_array( $term_obj ) && count( $term_obj ) > 0 ){
$selected_term_ids = isset( $data['terms'][$term_key] ) ? $data['terms'][$term_key] : false;
foreach ( $term_obj as $terms ) {
$extra_message = '';
// //if( 'product_cat' == $term_key ){
//
// $parents = get_term_parents_list($terms->term_id,$term_key, array(
// 'link' => false,
// 'separator'=> '/',
// 'inclusive'=> false,
// ));
// $parents = rtrim( $parents, '/' );
//
// if( ! empty( $parents ) ){
// $parents_exp = explode('/',$parents);
// $count = count( $parents_exp );
// //var_dump( str_repeat( '-', $count ) );
// $taxo_tree_sepa = apply_filters( 'wpto_taxonomy_tree_separator', '- ', $terms );
// $extra_message = str_repeat( $taxo_tree_sepa, $count );
// }
//
// //}
$selected = is_array( $selected_term_ids ) && in_array( $terms->term_id,$selected_term_ids ) ? 'selected' : false;
$options_item .= "<option value='{$terms->term_id}' {$selected}>{$terms->name} ({$terms->count})</option>";
$options_item .= "<option value='{$terms->term_id}' {$selected}>{$extra_message} {$terms->name} ({$terms->count})</option>";
}
}

Expand Down
61 changes: 60 additions & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1076,4 +1076,63 @@ function wpt_user_roles_by_id( $id )

return $user->roles;
}
}
}

if( !function_exists( 'wpt_shop_archive_sorting_args' ) ){

/**
* This function has fixed shop archive default sorting issue.
*
* @param type $args
* @return array $args
*/
function wpt_shop_archive_sorting_args( $args ){
if( is_shop() || is_product_taxonomy() ){
$_orderby = isset( $_GET['orderby'] ) && !empty( $_GET['orderby'] ) ? $_GET['orderby'] : '';
$args['paged'] = 1;
$args['post_type'] = ['product'];
switch( $_orderby ){
case 'price':
$args['orderby'] = 'meta_value_num';
$args['order'] = 'asc';
$args['meta_key'] = '_price';
break;
case 'price-desc':
$args['orderby'] = 'meta_value_num';
$args['order'] = 'desc';
$args['meta_key'] = '_price';
break;
case 'rating':
$args['orderby'] = 'meta_value_num';
$args['order'] = 'desc';
$args['meta_key'] = '_wc_average_rating';
break;
case 'popularity':
$args['orderby'] = 'meta_value_num';
$args['order'] = 'desc';
$args['meta_key'] = 'total_sales';
break;
case 'date':
$args['order'] = 'desc';
break;
}
}
return $args;
}
}
add_filter( 'wpto_table_query_args_in_row', 'wpt_shop_archive_sorting_args', 10 );

/**
* Astra Theme Compatibility
*
* Quantity Plus Minus Button issue solved by removed from Theme
* Only for Astra Theme
*
* TIPS: At this situation, Need https://wordpress.org/plugins/wc-quantity-plus-minus-button/ Plugin
*
* @since 2.8.3.2
*
* @date 3.2.2021
* @by Saiful
*/
add_filter( 'astra_add_to_cart_quantity_btn_enabled', '__return_false' );
4 changes: 2 additions & 2 deletions includes/items/total.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

$user_role = wpt_user_roles_by_id( get_current_user_id() );
$wholesale_meta_key = $user_role[0] . '_wholesale_price'; //It's only for Wholesale plugin
$total_price = !empty( get_post_meta($product->id, $wholesale_meta_key, true) )? get_post_meta($product->id, $wholesale_meta_key, true) : $product->get_price();
$total_price = !empty( get_post_meta($product->get_id(), $wholesale_meta_key, true) )? get_post_meta($product->get_id(), $wholesale_meta_key, true) : $product->get_price();

/**
* Filter for Getting original Flat price to calculate Total
Expand All @@ -38,7 +38,7 @@
* @Date 31.1.2021
* @by Saiful
*/
$total_price = apply_filters( 'wpto_flat_product_price', $total_price, $product->id, get_current_user_id(), $user_role, $product );
$total_price = apply_filters( 'wpto_flat_product_price', $total_price, $product->get_id(), get_current_user_id(), $user_role, $product );
echo "<div data-number_of_decimal='" . esc_attr( $number_of_decimal ) . "' "
. "data-thousand_separator='" . esc_attr( $thousand_separator ) . "' "
. "data-price_decimal_separator='" . esc_attr( $price_decimal_separator ) . "' "
Expand Down
58 changes: 31 additions & 27 deletions includes/variation_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,38 @@
<?php foreach ( $attributes as $attribute_name => $options ) : ?>

<?php
$show_label = isset( $config_value['wpto_show_variation_label2'] ) && $config_value['wpto_show_variation_label2'] == 'on' ? true : false;
echo $show_label ? '<div class="variation-wrapper">' : '';
/**
* This hooked is used for print variations label
*
* @hooked wpto_before_each_variation_callback - 10
*/
do_action( 'wpto_before_each_variation', $attribute_name, $options, $product, $config_value, $temp_number );
/**
* This hooked is used for print variations label
*
* for using for each variation
*/
do_action( 'wpto_before_each_variation', $attribute_name, $options, $product, $config_value, $temp_number );

$show_label = isset( $config_value['wpt_show_variation_label'] ) && $config_value['wpt_show_variation_label'] == 'on' ? true : false;
echo $show_label ? '<div class="variation-wrapper">' : '';
?>
<label for="<?php echo esc_attr( esc_attr( $attribute_name . '_' . $product->get_id() ) );?>"><?php echo esc_html( wc_attribute_label( $attribute_name ) ); ?></label>
<?php

wc_dropdown_variation_attribute_options(
array(
'options' => $options,
'attribute' => $attribute_name,
'product' => $product,
'id' => esc_attr( $attribute_name . '_' . $product->get_id() ),
'name' => esc_attr( $attribute_name . '_' . $product->get_id() ),
'show_option_none' => wc_attribute_label( $attribute_name ), // WPCS: XSS ok.
)
);
echo $show_label ? '</div>' : '';
if(end( $attribute_keys ) == $attribute_name){
if( $show_label ){
echo wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '<div class="variation-wrapper reset"><a class="reset_variations" href="#">' . esc_html__( 'Clear', 'woocommerce' ) . '</a></div>' ) );
}else{
echo wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '<a class="reset_variations" href="#">' . esc_html__( 'Clear', 'woocommerce' ) . '</a>' ) );
}
}
wc_dropdown_variation_attribute_options(
array(
'options' => $options,
'attribute' => $attribute_name,
'product' => $product,
'id' => esc_attr( $attribute_name . '_' . $product->get_id() ),
'name' => esc_attr( $attribute_name . '_' . $product->get_id() ),
'show_option_none' => wc_attribute_label( $attribute_name ), // WPCS: XSS ok.
)
);
echo $show_label ? '</div>' : '';

if( end( $attribute_keys ) == $attribute_name ){
if( $show_label ){
echo wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '<div class="variation-wrapper reset"><a class="reset_variations" href="#">' . esc_html__( 'Clear', 'woocommerce' ) . '</a></div>' ) );
}else{
echo wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '<a class="reset_variations" href="#">' . esc_html__( 'Clear', 'woocommerce' ) . '</a>' ) );
}
}
?>

<?php endforeach; ?>
Expand Down
Loading

0 comments on commit 38d983e

Please sign in to comment.