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 September 14, 2019 08:41
Show store name on single product page
/*Show store name on single product*/
add_action( 'woocommerce_single_product_summary', 'seller_name_on_single', 12 );
function seller_name_on_single(){
global $product;
$seller = get_post_field( 'post_author', $product->get_id());
$author = get_user_by( 'id', $seller );
$vendor = dokan()->vendor->get( $seller );
$store_info = dokan_get_store_info( $author->ID );
@nayemDevs
nayemDevs / functions.php
Last active April 11, 2023 19:16
re-order tab on single product page
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
$tabs['reviews']['priority'] = 5; // Reviews first
$tabs['description']['priority'] = 10; // Description second
$tabs['additional_information']['priority'] = 15; // Additional information third
return $tabs;
}
@nayemDevs
nayemDevs / functions.php
Last active February 15, 2022 14:11
deleting product image when deleting a product in Dokan
<?php
add_action( 'before_delete_post', function( $id ) {
$product = wc_get_product( $id );
if ( ! $product ) {
return;
}
$all_product_ids = [];
$product_thum_id_holder = [];
$gallery_image_id_holder = [];
@nayemDevs
nayemDevs / functions.php
Last active February 26, 2025 00:01
Creating a shortcode to show vendor biography anywhere on your page
<?php
/**
* Plugin Name: Dokan Vendor Biography Shortcode
*/
add_shortcode( 'dokan_vendor_bio', 'dokan_vendor_bio_shortcode' );
function dokan_vendor_bio_shortcode() {
$vendor = dokan()->vendor->get( get_query_var( 'author' ) );
$store_info = $vendor->get_shop_info();
if ( empty( $store_info['vendor_biography'] ) ) {
return;
<?php
Just need basic.- only USA
Name:
State:
Occupation: {"data":[{"id":117,"name":"Physician"}
Specialties: {"occupation_ids":[117],"id":1144,"name":"Emergency Med-Pediatric"},{"occupation_ids":[519,518,517,516,515,514,512,511,510,509,507,505,504,503,502,501,500,498,497,496,495,118,117],"id":878,"name":"Other"}
Must meet Keywords to pass True: Pediatrics, Pediatricians, Pediatric Hospitalist
@nayemDevs
nayemDevs / functions.php
Last active March 17, 2020 09:32
Changing default thumbnail image of WooCommerce product
<?php
/**
* Change the placeholder image
*/
add_filter('woocommerce_placeholder_img_src', 'custom_woocommerce_placeholder_img_src');
function custom_woocommerce_placeholder_img_src( $src ) {
$upload_dir = wp_upload_dir();
$uploads = untrailingslashit( $upload_dir['baseurl'] );
@nayemDevs
nayemDevs / functions.php
Last active April 12, 2021 23:42
Move Dokan vendor dashboard Settings menu to before the settings (First page)
<?php
//removeing the menu from settings variable
add_filter( 'dokan_get_dashboard_settings_nav', function($settings_sub) {
unset ( $settings_sub['store']);
return $settings_sub;
} , 500);
//adding the menu to the $url variable
add_filter('dokan_get_dashboard_nav',function($url) {
@nayemDevs
nayemDevs / functions.php
Created April 14, 2020 08:41
Show wholesale migration button for vendor on my-account page
<?php
add_action( 'woocommerce_after_my_account', 'dokan_vendor_wholesale_btn' );
function dokan_vendor_wholesale_btn() {
$user_id = get_current_user_id();
$user = get_user_by( 'id', $user_id );
$wholesale_customer = metadata_exists( 'user', $user_id, '_is_dokan_wholesale_customer' );
?>
<?php if ( $wholesale_customer ): ?>
<?php if ( ! $user->has_cap( 'dokan_wholesale_customer' ) ): ?>
<li class="dokan-wholesale-migration-wrapper">
@nayemDevs
nayemDevs / functions.php
Last active July 28, 2022 11:27
Show store name on single product page (Sold by: vendor) when you have created single product via Elementor
/**
* Show sold by on single product page made with Elementor
* Add the shortcode [dokan_vendor_name] through a short-code widget on single product page
*/
add_shortcode( 'dokan_vendor_name', 'dokan_store_name_shortcode' );
function dokan_store_name_shortcode() {
$seller = get_post_field( 'post_author' );
$author = get_user_by( 'id', $seller );
$vendor = dokan()->vendor->get( $seller );
@nayemDevs
nayemDevs / functions.php
Last active August 12, 2024 09:14
Saving extra field value and showing on user profile = vendor registration form
function dokan_custom_seller_registration_required_fields( $required_fields ) {
$required_fields['gst_id'] = __( 'Please enter your GST number', 'dokan-custom' );
return $required_fields;
};
add_filter( 'dokan_seller_registration_required_fields', 'dokan_custom_seller_registration_required_fields' );