Skip to content

Instantly share code, notes, and snippets.

Md. Nazmul Hassan nayemDevs

View GitHub Profile
@nayemDevs
nayemDevs / functions.php
Created Jul 14, 2020
Exclude specific vendor by ID from store-list page
View functions.php
<?php
/**
* Exclude some sellers from vendor query
*
* @param $seller_args
* @return mixed
*/
function exclude_some_sellers_users( $seller_args ) {
$seller_args['exclude'] = array( 8 ); // add here Users IDs
return $seller_args;
@nayemDevs
nayemDevs / functions.php
Last active Jun 28, 2020
Add new field on vendor product upload form in Dokan
View functions.php
<?php
/*
* 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(){ ?>
@nayemDevs
nayemDevs / functions.php
Last active Jun 18, 2020
Saving extra field value and showing on user profile = vendor registration form
View functions.php
<?
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' );
@nayemDevs
nayemDevs / functions.php
Created Apr 27, 2020
Show store name on single product page (Sold by: vendor) when you have created single product via Elementor
View functions.php
/**
* 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() {
global $product;
$seller = get_post_field( 'post_author', $product->get_id());
$author = get_user_by( 'id', $seller );
$vendor = dokan()->vendor->get( $seller );
@nayemDevs
nayemDevs / functions.php
Created Apr 14, 2020
Show wholesale migration button for vendor on my-account page
View functions.php
<?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 Mar 29, 2020
Move Dokan vendor dashboard Settings menu to before the settings (First page)
View functions.php
<?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
Last active Mar 17, 2020
Changing default thumbnail image of WooCommerce product
View functions.php
<?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'] );
View functions.php
<?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
Created Dec 13, 2019
Creating a shortcode to show vendor biography anywhere on your page
View functions.php
<?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;
@nayemDevs
nayemDevs / functions.php
Last active May 4, 2020
deleting product image when deleting a product in Dokan
View functions.php
<?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 = [];
You can’t perform that action at this time.