Skip to content

Instantly share code, notes, and snippets.

@alamgircsebd
Last active April 5, 2021 07:29
Show Gist options
  • Save alamgircsebd/3d721ee96020f39a8818c552016f3ac6 to your computer and use it in GitHub Desktop.
Save alamgircsebd/3d721ee96020f39a8818c552016f3ac6 to your computer and use it in GitHub Desktop.
Currency switcher support
/**
* Add this codes on your parent/child theme functions.php or use custom plugin for add php scripts
*/
if ( ! function_exists( 'dokan_woocs_recalculate_order_payment_completed' ) ) {
/**
* Recalculate order for wc currency switcher support
*
* @param int $order_id
*
* @return bool
*/
function dokan_woocs_recalculate_order_payment_completed( $order_id ) {
if ( class_exists( 'WOOCS' ) ) {
global $WOOCS;
$WOOCS->recalculate_order( $order_id );
}
}
}
add_action( 'woocommerce_order_status_completed', 'dokan_woocs_recalculate_order_payment_completed', 1 );
add_action( 'woocommerce_payment_complete', 'dokan_woocs_recalculate_order_payment_completed' );
add_filter( 'wp_head', function() {
if ( function_exists( 'dokan_is_seller_dashboard' ) && dokan_is_seller_dashboard() && class_exists( 'WOOCS' ) ) {
global $WOOCS;
$WOOCS->reset_currency();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment