This plugin is designed to integrate with the Dokan plugin and requires Dokan to be installed and activated. Upon activation, the plugin will upload three tables to the database, namely:
- cu_sendcloud_webhook: Contains webhook calls.
- cu_sendcloud_credentials: Stores API keys of SendCloud.
- cu_sendcloud_parcels: Contains parcel entries in the Database.
To display the order details in the vendor dashboard, use the following code snippet:
$user_order_number = esc_attr(dokan_get_prop($order, 'id'));
if (function_exists('display_create_label_button')) {
display_create_label_button($user_order_number);
}
To display the list of carriers chosen by the seller in the vendor dashboard, use the following code snippet:
echo do_shortcode('[custom_shipping_form]');
Use the following code in WooCommerce to override or display the shipping price. The post_author_id
is used to post the user ID of the vendor of the product.
function custom_wc_shipping_package_name($package_name, $i, $package, $post_author_id) {
$custom_package_name = __('Shipping', 'woocommerce') . "
" . do_shortcode('[display_shipping_courier user_id="' . $post_author_id . '"]');
return $custom_package_name;
}
add_filter('woocommerce_shipping_package_name', function ($package_name, $i, $package) use ($post_author_id) {
return custom_wc_shipping_package_name($package_name, $i, $package, $post_author_id);
}, 99, 3);
To automatically create a label when the payment is successful, use the following code snippet:
$pdfFileName = create_autolabel_on_order($order_id_to_trigger);
This will create a label on SendCloud and return the PDF file, which can be used to send an email to the vendor.
Make sure to configure the SendCloud API keys in the cu_sendcloud_credentials
table for proper integration.
Feel free to reach out for any issues or further assistance. Happy shipping!