Skip to content

Instantly share code, notes, and snippets.

View nayemDevs's full-sized avatar

Md. Nazmul Hassan nayemDevs

View GitHub Profile
@nayemDevs
nayemDevs / functions.php
Last active November 29, 2023 22:58
Add new field on vendor product upload form in Dokan
/*
* Adding extra field on New product popup/without popup form
*/
add_action( 'dokan_new_product_after_product_tags','new_product_field',10 );
function new_product_field(){ ?>
<div class="dokan-form-group">
@nayemDevs
nayemDevs / functions.php
Last active September 14, 2020 05:07
Exclude specific vendor by ID from store-list page
<?php
/**
* Exclude admin roles from vendor query
*
* @param $seller_args
* @return mixed
*/
function exclude_some_sellers_users( $seller_args ) {
$seller_args['role__in'] = array( 'seller' ); // add here roles
return $seller_args;
@nayemDevs
nayemDevs / functions.php
Last active July 17, 2024 15:06
Price and Image field required
/**
* Validation add for product cover image
*
* @param array $errors
* @return array $errors
*/
function dokan_can_add_product_validation_customized( $errors ) {
$postdata = wp_unslash( $_POST );
$featured_image = absint( sanitize_text_field( $postdata['feat_image_id'] ) );
$_regular_price = absint( sanitize_text_field( $postdata['_regular_price'] ) );
@nayemDevs
nayemDevs / functions.php
Last active September 9, 2021 02:08
Shipping class option required on single product page
function dokan_can_edit_product_shipping_filed_validation( $errors ) {
if ( stripslashes( isset( $_POST['_disable_shipping'] ) ) && 'yes' == $_POST['_disable_shipping'] ) {
$errors[] = __( 'Please select shipping option', 'dokan-lite' );
}
if ( $_POST['product_shipping_class'] < 1 ) {
$errors[] = __( 'Please select shipping class', 'dokan-lite' );
}
return $errors;
}
add_filter( 'dokan_can_edit_product', 'dokan_can_edit_product_shipping_filed_validation', 35, 1 );
@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;
}
@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 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 / 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 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
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 = [