return $template;
}
if ( ! current_user_can( 'dokan_edit_product' ) ) {
return $template;
}
if ( ! ( get_query_var( 'edit' ) && is_singular( 'product' ) ) ) {
return $template;
}
$edit_product_url = dokan_locate_template( 'products/edit-product-single.php' );
return apply_filters( 'dokan_get_product_edit_template', $edit_product_url );
}
/**
* Remove h1 tag in edit product page.
*
* @param $args
*
* @return mixed
*/
public function remove_h1_from_heading_in_edit_product_page( $args ) {
global $wp;
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( ( dokan_is_seller_dashboard() && isset( $wp->query_vars['settings'] ) && $wp->query_vars['settings'] === 'store' ) || ( ! empty( $_GET['product_id'] ) && ! empty( $_GET['action'] ) && ! empty( $_GET['_dokan_edit_product_nonce'] ) ) ) {
// Just omit h1 from the list
$args['block_formats'] = 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Pre=pre';
return $args;
}
return $args;
}
/**
* Store query filter
*
* Handles the product filtering by category in store page
*
* @param object $query
*
* @return void
*/
public function store_query_filter( $query ) {
global $wp_query;
$author = get_query_var( $this->custom_store_url );
if ( ! is_admin() && $query->is_main_query() && ! empty( $author ) ) {
$seller_info = get_user_by( 'slug', $author );
if ( ! $seller_info ) {
return get_404_template();
}
$store_info = dokan_get_store_info( $seller_info->data->ID );
$product_ppp = dokan_get_option( 'store_products_per_page', 'dokan_general', 12 );
do_action( 'dokan_store_page_query_filter', $query, $store_info );
set_query_var( 'posts_per_page', apply_filters( 'dokan_store_products_per_page', $product_ppp ) );
$query->set( 'post_type', 'product' );
$query->set( 'author_name', $author );
$tax_query = [];
$query->query['term_section'] = isset( $query->query['term_section'] ) ? $query->query['term_section'] : [];
$attributes = dokan_get_chosen_taxonomy_attributes();
if ( ! empty( $attributes ) ) {
foreach ( $attributes as $key => $attribute ) {
$tax_query[] = [
'taxonomy' => $key,
'field' => 'slug',
'terms' => $attribute['terms'],
];
}
}
if ( $query->query['term_section'] ) {
array_push(
$tax_query, [
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $query->query['term'],
]
);
}
// Hide out of stock products
$product_visibility_terms = wc_get_product_visibility_term_ids();
$product_visibility_not_in = [ is_search() && $query->is_main_query() ? $product_visibility_terms['exclude-from-search'] : $product_visibility_terms['exclude-from-catalog'] ];
if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
$product_visibility_not_in[] = $product_visibility_terms['outofstock'];
}
if ( ! empty( $product_visibility_not_in ) ) {
array_push(
$tax_query, [
'taxonomy' => 'product_visibility',
'field' => 'term_taxonomy_id',
'terms' => $product_visibility_not_in,
'operator' => 'NOT IN',
]
);
}
$query->set( 'tax_query', apply_filters( 'dokan_store_tax_query', $tax_query ) );
if ( ! empty( $_GET['product_name'] ) ) { //phpcs:ignore
$product_name = wc_clean( wp_unslash( $_GET['product_name'] ) ); //phpcs:ignore
$query->set( 's', $product_name );
}
// set orderby param
$ordering = $this->get_catalog_ordering_args();
$query->set( 'orderby', $ordering['orderby'] );
$query->set( 'order', $ordering['order'] );
}
}
/**
* Returns an array of arguments for ordering products based on the selected values.
*
* @since DOKAN_LITE_SINCE
*
* @param string $orderby Order by param
* @param string $order Order param
*
* @return array
*/
public function get_catalog_ordering_args( $orderby = '', $order = '' ) {
// Get ordering from query string unless defined.
if ( ! $orderby ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$orderby_value = isset( $_GET['product_orderby'] ) ? wc_clean( wp_unslash( $_GET['product_orderby'] ) ) : wc_clean( get_query_var( 'product_orderby' ) ); //phpcs:ignore
if ( ! $orderby_value ) {
if ( is_search() ) {
$orderby_value = 'relevance';
} else {
$orderby_value = apply_filters( 'dokan_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby', 'menu_order' ) );
}
}
// Get order + orderby args from string.
$orderby_value = is_array( $orderby_value ) ? $orderby_value : explode( '-', $orderby_value );
$orderby = esc_attr( $orderby_value[0] );
$order = ! empty( $orderby_value[1] ) ? $orderby_value[1] : $order;
}
// Convert to correct format.
$orderby = strtolower( is_array( $orderby ) ? (string) current( $orderby ) : (string) $orderby );
$order = strtoupper( is_array( $order ) ? (string) current( $order ) : (string) $order );
$args = array(
'orderby' => $orderby,
'order' => ( 'DESC' === $order ) ? 'DESC' : 'ASC',
'meta_key' => '', // @codingStandardsIgnoreLine
);
switch ( $orderby ) {
case 'id':
$args['orderby'] = 'ID';
break;
case 'menu_order':
$args['orderby'] = 'menu_order title';
break;
case 'title':
$args['orderby'] = 'title';
$args['order'] = ( 'DESC' === $order ) ? 'DESC' : 'ASC';
break;
case 'relevance':
$args['orderby'] = 'relevance';
$args['order'] = 'DESC';
break;
case 'rand':
$args['orderby'] = 'rand'; // @codingStandardsIgnoreLine
break;
case 'date':
$args['orderby'] = 'date ID';
$args['order'] = ( 'ASC' === $order ) ? 'ASC' : 'DESC';
break;
case 'price':
$callback = 'DESC' === $order ? 'order_by_price_desc_post_clauses' : 'order_by_price_asc_post_clauses';
add_filter( 'posts_clauses', [ $this, $callback ] );
break;
case 'popularity':
add_filter( 'posts_clauses', [ $this, 'order_by_popularity_post_clauses' ] );
break;
case 'rating':
add_filter( 'posts_clauses', [ $this, 'order_by_rating_post_clauses' ] );
break;
}
return apply_filters( 'dokan_get_store_products_ordering_args', $args, $orderby, $order );
}
/**
* Handle numeric price sorting
*
* @since DOKAN_LITE_SINCE
*
* @param array $args Query args
*
* @return array
*/
public function order_by_price_asc_post_clauses( $args ) {
$args['join'] = $this->append_product_sorting_table_join( $args['join'] );
$args['orderby'] = ' wc_product_meta_lookup.min_price ASC, wc_product_meta_lookup.product_id ASC ';
return $args;
}
/**
* Handle numeric price sorting
*
* @since DOKAN_LITE_SINCE
*
* @param array $args Query args
*
* @return array
*/
public function order_by_price_desc_post_clauses( $args ) {
$args['join'] = $this->append_product_sorting_table_join( $args['join'] );
$args['orderby'] = ' wc_product_meta_lookup.max_price DESC, wc_product_meta_lookup.product_id DESC ';
return $args;
}
/**
* WP Core does not let us change the sort direction for individual orderby params
*
* This lets us sort by meta value desc, and have a second orderby param
*
* @since DOKAN_LITE_SINCE
*
* @param array $args Query args
*
* @return array
*/
public function order_by_popularity_post_clauses( $args ) {
$args['join'] = $this->append_product_sorting_table_join( $args['join'] );
$args['orderby'] = ' wc_product_meta_lookup.total_sales DESC, wc_product_meta_lookup.product_id DESC ';
return $args;
}
/**
* Order by rating post clauses
*
* @since DOKAN_LITE_SINCE
*
* @param array $args Query args
*
* @return array
*/
public function order_by_rating_post_clauses( $args ) {
$args['join'] = $this->append_product_sorting_table_join( $args['join'] );
$args['orderby'] = ' wc_product_meta_lookup.average_rating DESC, wc_product_meta_lookup.rating_count DESC, wc_product_meta_lookup.product_id DESC ';
return $args;
}
/**
* Join wc_product_meta_lookup to posts if not already joined.
*
* @since DOKAN_LITE_SINCE
*
* @param string $sql SQL join
*
* @return string
*/
private function append_product_sorting_table_join( $sql ) {
global $wpdb;
if ( ! strstr( $sql, 'wc_product_meta_lookup' ) ) {
$sql .= " LEFT JOIN {$wpdb->wc_product_meta_lookup} wc_product_meta_lookup ON $wpdb->posts.ID = wc_product_meta_lookup.product_id ";
}
return $sql;
}
}
Fatal error: Uncaught WeDevs\Dokan\ThirdParty\Packages\League\Container\Exception\ContainerException: Service provider lied about providing (WeDevs\Dokan\Rewrites) service in /home/abauctio/public_html/wp-content/plugins/dokan-lite/lib/packages/League/Container/Container.php:195
Stack trace:
#0 /home/abauctio/public_html/wp-content/plugins/dokan-lite/lib/packages/League/Container/Container.php(118): WeDevs\Dokan\ThirdParty\Packages\League\Container\Container->resolve('WeDevs\\Dokan\\Re...')
#1 /home/abauctio/public_html/wp-content/plugins/dokan-lite/lib/packages/League/Container/Definition/Definition.php(204): WeDevs\Dokan\ThirdParty\Packages\League\Container\Container->get('WeDevs\\Dokan\\Re...')
#2 /home/abauctio/public_html/wp-content/plugins/dokan-lite/lib/packages/League/Container/Definition/Definition.php(160): WeDevs\Dokan\ThirdParty\Packages\League\Container\Definition\Definition->resolveNew()
#3 /home/abauctio/public_html/wp-content/plugins/dokan-lite/lib/packages/League/Container/Definition/DefinitionAggregate.p in /home/abauctio/public_html/wp-content/plugins/dokan-lite/lib/packages/League/Container/Container.php on line 195