Skip to content

Commit

Permalink
Merge pull request #55 from shohag121/update/vendor-subscription-prod…
Browse files Browse the repository at this point in the history
…uct-query

update: Vendor Subscription remaining product count WPML Support
  • Loading branch information
Aunshon authored Apr 1, 2024
2 parents a5ef6ba + 09e4197 commit 073c784
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions dokan-wpml.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public function plugins_loaded() {
add_filter( 'dokan_dashboard_nav_submenu_key', [ $this, 'filter_dashboard_settings_key' ] );
add_filter( 'wcml_vendor_addon_configuration', [ $this, 'add_vendor_capability' ] );
add_filter('icl_lang_sel_copy_parameters', [ $this, 'set_language_switcher_copy_param' ] );
add_filter( 'dokan_vendor_subscription_product_count_query', [ $this, 'set_vendor_subscription_product_count_query' ],10 ,3 );

add_action( 'init', [ $this, 'fix_store_category_query_arg' ], 10 );
add_action( 'init', [ $this, 'load_wpml_admin_post_actions' ], 10 );
Expand Down Expand Up @@ -636,6 +637,36 @@ public function dokan_get_translated_page_id( $page_id ) {
return wpml_object_id_filter( $page_id, 'page', true, ICL_LANGUAGE_CODE );
}

/**
* Set Vendor Subscription product count query on based language.
*
* @since 1.1.1
*
* @param string $query Product Query.
* @param int $vendor_id Vendor Id.
* @param array $allowed_status Allowed Status.
*
* @return string
*/
public function set_vendor_subscription_product_count_query( $query, $vendor_id, $allowed_status ) {
global $wpdb;

$status = "'" . implode( "','", $allowed_status ) . "'";

return $wpdb->prepare(
"SELECT count( DISTINCT wpml_translations.trid ) as total
FROM {$wpdb->prefix}posts as posts
JOIN {$wpdb->prefix}icl_translations wpml_translations
ON posts.ID = wpml_translations.element_id
AND wpml_translations.element_type = CONCAT('post_', posts.post_type)
WHERE 1=1
AND posts.post_type = 'product'
AND posts.post_author = %d
AND posts.post_status IN ( {$status} )
",
$vendor_id
);
}

/**
* Store Vendor Subscription pack in default language.
Expand Down

0 comments on commit 073c784

Please sign in to comment.