Skip to content

Instantly share code, notes, and snippets.

@kilbot
Created July 3, 2024 20:29
Show Gist options
  • Save kilbot/17c1740a4771b3ded2ef48d900fa56e6 to your computer and use it in GitHub Desktop.
Save kilbot/17c1740a4771b3ded2ef48d900fa56e6 to your computer and use it in GitHub Desktop.
WooCommerce Bottle Deposit Plugin REST API integration
<?php
/**
* Add this to your theme's functions.php file to save the bottle deposit on the order.
*/
function woocommerce_pos_save_order( $order, $request, $creating ) {
global $WooCommerce_Bottle_Deposit;
if ( isset( $WooCommerce_Bottle_Deposit ) && class_exists( 'WooCommerce_Bottle_Deposit_Admin' ) ) {
$wc_bottle_deposit_admin = new WooCommerce_Bottle_Deposit_Admin( $WooCommerce_Bottle_Deposit->get_plugin_name(), $WooCommerce_Bottle_Deposit->get_version() );
$wc_bottle_deposit_admin->handle_admin_orders( $order->get_id() );
}
}
add_action( 'woocommerce_rest_insert_shop_order_object', 'woocommerce_pos_save_order', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment