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 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
Last active March 12, 2024 15:13
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 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 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 November 29, 2023 23:18
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' );
@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
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 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
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'] );
<?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