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 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 January 29, 2024 08:39
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;
@nayemDevs
nayemDevs / new-menu.php
Last active December 4, 2023 15:46
Adding extra dashboard menu for Vendor Dashboard ( this code need to be inserted on your theme's functions.php)
<?php
//copy from below line
add_filter( 'dokan_query_var_filter', 'dokan_load_document_menu' );
function dokan_load_document_menu( $query_vars ) {
$query_vars['help'] = 'help';
return $query_vars;
}
@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 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 / extra-field.php
Last active September 19, 2023 16:10
Add extra field on vendor settings area and show the field value on the store banner
/*Extra field on the seller settings and show the value on the store banner -Dokan*/
// Add extra field in seller settings
add_filter( 'dokan_settings_form_bottom', 'extra_fields', 10, 2);
function extra_fields( $current_user, $profile_info ){
$seller_url= isset( $profile_info['seller_url'] ) ? $profile_info['seller_url'] : '';
?>
<div class="gregcustom dokan-form-group">
@nayemDevs
nayemDevs / functions.php
Last active August 29, 2023 08:29
Override seller setup-wizard via child-theme using Class
<?php
class Dokan_Setup_Wizard_Override extends Dokan_Seller_Setup_Wizard {
/**
* Introduction step.
*/
public function dokan_setup_introduction() {
$dashboard_url = dokan_get_navigation_url();
@nayemDevs
nayemDevs / functions.php
Last active April 11, 2023 19:19
Change Bank withdraw method fields in vendor dashboard settings in Dokan
<?php
/*
You can change any field title or remove any feild for the vendor -> settings -> payment -> bank transfer method. Please note that this
code need to be placed on your child-theme functions.php file
*/
add_filter( 'dokan_withdraw_methods', 'wp1923_change_whithdraw_callback', 12 );
function wp1923_change_whithdraw_callback( $methods ) {
@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 / 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 );