John Davidson

php - Adding Default WooCommerce Shipping to Dokan Vendor Dashboard

0 comments
Message:


We are using Dokan Multi-Vendor plugin for WooCommerce and they have their own shipping module which is not the way we need to work the site.


The users can go into the back-end admin and are able to set the shipping correctly, however Dokan offers a simpler dashboard for the vendors which we want it to integrate with this as users can get confused.


The piece that we want to replicate across looks like the below in the WooCommerce back-end. Is there a hook or code that we are able to expose this in a custom dashboard?



I have found where I would like to add the code within dokan/products/product-shipping-content.php. The Vendor Dashboard looks like below and I want it to slot in to the Shipping and Tax section and to update the same



Talking to support from the plugin support is proving fruitless. Is there a way to display the default WooCommerce shipping methods, as shown in 1st image, within a custom vendor dashboard?



My Answer:
To add the default WooCommerce shipping methods to the Dokan Vendor Dashboard, you can use the following code snippet:

php
add_action( 'dokan_product_edit_after_shipping', 'add_default_woocommerce_shipping_methods' );

function add_default_woocommerce_shipping_methods() {
global $woocommerce;

$shipping_methods = $woocommerce->shipping->load_shipping_methods();

foreach ( $shipping_methods as $method ) {
echo '

' . $method->method_title . '

';
echo '

' . $method->method_description . '

';
}
}


You can add this code to your theme's functions.php file or create a custom plugin for it. This code will display the default WooCommerce shipping methods in the Dokan Vendor Dashboard after the shipping section.

Please note that you may need to customize the code further to match the exact layout and styling of the Dokan Vendor Dashboard. Additionally, you may need to handle the saving of shipping methods selected by the vendor in the backend.

Rate this post

5 of 5 based on 7294 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us