Skip to content

Instantly share code, notes, and snippets.

View nayemDevs's full-sized avatar

Md. Nazmul Hassan nayemDevs

View GitHub Profile
@nayemDevs
nayemDevs / delete.php
Created January 4, 2023 04:29 — forked from alamgircsebd/delete.php
Scripts for Delete WooCommerce Products by User ID
<?php
$userID = 2;
$args = array( 'author' => $userID, 'post_type' => 'product', 'posts_per_page' => -1, 'post_status' => array( 'publish', 'pending', 'draft', 'future' ) );
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
wp_delete_post( get_the_ID(), true );
@nayemDevs
nayemDevs / functions.php
Created August 16, 2021 11:19
Enable Downloadable & Virtual by default
/**
* Dokan product page downloadable and virtual force always checked
*/
function dokan_product_page_downloadable_virtual_checkbox_force_checked() {
if ( is_user_logged_in() && function_exists( 'dokan_is_seller_dashboard' ) && dokan_is_seller_dashboard() ) {
?>
<script>
(function($) {
var Dokan_Product_Virtual_Download_Checkbox_Customized = {
init: function() {
@nayemDevs
nayemDevs / functions.php
Created June 8, 2021 03:03
Set I am a vendor by default
remove_action( 'woocommerce_register_form', 'dokan_seller_reg_form_fields' );
add_action( 'woocommerce_register_form', 'dokan_custom_reg_vendor_selected', 12 );
function dokan_custom_reg_vendor_selected() {
$postdata = wc_clean( $_POST ); // WPCS: CSRF ok, input var ok.
$role = isset( $postdata['role'] ) ? $postdata['role'] : 'seller';
$role_style = ( $role == 'customer' ) ? 'display:none' : '';
dokan_get_template_part( 'global/seller-registration-form', '', array(
'postdata' => $postdata,
'role' => $role,
@nayemDevs
nayemDevs / functions.php
Created May 2, 2021 03:33
Increase product list column on store page
#-- Modify the number of products column of the single store page --#
function single_store_page_product_columns($columns){
if(dokan_is_store_page()){
return $columns = 4;
} else {
return $columns;
}
}
add_filter( 'loop_shop_columns', 'single_store_page_product_columns');
@nayemDevs
nayemDevs / functions.php
Last active August 18, 2021 14:08
Random order on store-list page
<?php
function dokan_store_listing_orderby_ramdom_filter( $seller_args ) {
$seller_args['orderby'] = 'dokan_store_rand';
return $seller_args;
}
add_filter( 'dokan_seller_listing_args', 'dokan_store_listing_orderby_ramdom_filter', 99 );
function dokan_store_listing_orderby_filter_query( $query ) {
if ( $query->query_vars['orderby'] === 'dokan_store_rand' ) {
$order_by = [
@nayemDevs
nayemDevs / functions.php
Created February 2, 2021 04:00
Show only free shipping and hide other shipping methods
/**
* Hide shipping rates when free shipping is available.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function dokan_vendor_shipping_hide_when_free_is_available( $rates ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
@nayemDevs
nayemDevs / functions.php
Created December 10, 2020 09:20
Show notice on vendor store & single product page
/* Store notice field seller settings */
add_filter( 'dokan_settings_form_bottom', 'extra_fields', 10, 2);
function extra_fields( $current_user, $profile_info ){
$booth_news= get_user_meta( $current_user, 'booth_news', true );
?>
<div class="gregcustom dokan-form-group">
<label class="dokan-w3 dokan-control-label" for="setting_address">
<?php _e( 'Store Notice', 'dokan' ); ?>
</label>
@nayemDevs
nayemDevs / functions.php
Created November 21, 2020 07:22
How to show customer avatar on my-account page of WooCommerce
//showing avatar on my-account page
function showing_custom_avatar(){
$current_user = wp_get_current_user();
echo'<div class="myaccount_custom">'.get_avatar($current_user->user_email,72,'',$current_user->display_name). '</div>';
}
@nayemDevs
nayemDevs / gist:d732f60608345c40532c92021987bf8e
Last active March 3, 2022 02:49
Process of adding custom order status on Dokan for vendor
You may need to do custom code to show your custom order status on the frontend in both order list and order details.php.
When you will add new order Status for WooCommerce you need to use the same filter to ADD NEW CASE to show and save the
order status when someone updates the order and to send order status changes through order-notes on the frontend.
Kindly use the below hooks to get it done.
dokan_get_order_status_translated & dokan_get_order_status_class
Kindly open dokan-lite/templates/orders/listing.php and check this filter- dokan_bulk_order_statuses which should help you.
@nayemDevs
nayemDevs / functions.php
Created November 7, 2020 04:56
Removing tabs from single product page
add_filter('woocommerce_product_tabs','remove_wc_tab',12);
function remove_wc_tab($tabs){
unset($tabs['reviews']); //removing review tab
unset($tabs['additional_information']); //removing additional info tab
return $tabs;
}