Changeset 2526845
- Timestamp:
- 05/05/2021 06:43:49 PM (5 years ago)
- Location:
- bux-woocommerce/trunk
- Files:
-
- 2 edited
-
bux-plugin.php (modified) (6 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bux-woocommerce/trunk/bux-plugin.php
r2503114 r2526845 4 4 * Plugin URI: https://bux.ph/static/bux-plugin-wp.zip 5 5 * Description: Bux plugin for Woocommerce, you need to have Woocommerce installed 6 * Version: 1.1. 26 * Version: 1.1.3 7 7 * Author: UBX Philippines 8 8 * Author URI: https://bux.ph … … 40 40 ); 41 41 } 42 43 44 function restore_order_stock( $order ) { 45 $items = $order->get_items(); 46 47 if ( ! get_option('woocommerce_manage_stock') == 'yes' && ! count( $items ) > 0 ) 48 return; // We exit 49 50 foreach ( $order->get_items() as $item ) { 51 $product_id = $item->get_product_id(); 52 53 if ( $product_id > 0 ) { 54 $product = $item->get_product(); 55 56 if ( $product && $product->exists() && $product->managing_stock() ) { 57 58 $initial_stock = $product->get_stock_quantity(); 59 60 $item_qty = apply_filters( 'woocommerce_order_item_quantity', $item->get_quantity(), $order, $item ); 61 62 wc_update_product_stock( $product, $item_qty, 'increase' ); 63 64 $updated_stock = $initial_stock + $item_qty; 65 66 do_action( 'woocommerce_auto_stock_restored', $product, $item ); 67 68 $order_note[] = sprintf( __( 'Product ID #%s stock incremented from %s to %s.', 'woocommerce' ), $product_id, $initial_stock, $updated_stock); 69 70 } 71 } 72 } 73 74 $order_notes = count($order_note) > 1 ? implode(' | ', $order_note) : $order_note[0]; 75 $order->add_order_note( $order_notes ); 76 } 77 42 78 function bux_update_order($request) { 43 79 … … 60 96 } 61 97 $order = wc_get_order($order_id); 98 $pre_order_status = $order->get_status(); 62 99 63 100 if (empty($order)) { … … 65 102 66 103 } 67 $order->update_status( $order_status, __( 'Awaiting payment', 'bux-gateway' ) ); 104 105 if($order_status == "wc-cancelled" && $pre_order_status != "wc-cancelled"){ 106 #only restore stock if not yet cancelled 107 restore_order_stock($order); 108 $order->update_status( $order_status, __( 'Payment Expired/Cancelled', 'bux-gateway' ) ); 109 }else if($order_status == "wc-processing" && $pre_order_status != "wc-processing"){ 110 $order->update_status( $order_status, __( 'Payment Successful', 'bux-gateway' ) ); 111 }else{ 112 $order->update_status( $order_status, __( 'Status Update', 'bux-gateway' ) ); 113 114 } 68 115 return rest_ensure_response( '{"code": "success"}' ); 69 116 } 117 70 118 71 119 … … 207 255 ) ); 208 256 209 register_post_status( 'wc-paid-bux', array(210 'label' => _x( 'Paid via Bux', 'WooCommerce Order status', 'text_domain' ),211 'public' => true,212 'exclude_from_search' => false,213 'show_in_admin_all_list' => true,214 'show_in_admin_status_list' => true,215 'label_count' => _n_noop( 'Approved (%s)', 'Approved (%s)', 'text_domain' )216 ) );217 218 register_post_status( 'wc-pre-shipping', array(219 'label' => _x( 'Pre Shipping', 'WooCommerce Order status', 'text_domain' ),220 'public' => true,221 'exclude_from_search' => false,222 'show_in_admin_all_list' => true,223 'show_in_admin_status_list' => true,224 'label_count' => _n_noop( 'Approved (%s)', 'Approved (%s)', 'text_domain' )225 ) );226 227 register_post_status( 'wc-pre-transit', array(228 'label' => _x( 'Pre Transit', 'WooCommerce Order status', 'text_domain' ),229 'public' => true,230 'exclude_from_search' => false,231 'show_in_admin_all_list' => true,232 'show_in_admin_status_list' => true,233 'label_count' => _n_noop( 'Approved (%s)', 'Approved (%s)', 'text_domain' )234 ) );235 236 register_post_status( 'wc-in-transit', array(237 'label' => _x( 'In Transit', 'WooCommerce Order status', 'text_domain' ),238 'public' => true,239 'exclude_from_search' => false,240 'show_in_admin_all_list' => true,241 'show_in_admin_status_list' => true,242 'label_count' => _n_noop( 'Approved (%s)', 'Approved (%s)', 'text_domain' )243 ) );244 245 register_post_status( 'wc-delivered', array(246 'label' => _x( 'Delivered', 'WooCommerce Order status', 'text_domain' ),247 'public' => true,248 'exclude_from_search' => false,249 'show_in_admin_all_list' => true,250 'show_in_admin_status_list' => true,251 'label_count' => _n_noop( 'Approved (%s)', 'Approved (%s)', 'text_domain' )252 ) );253 257 } 254 258 add_filter( 'init', 'bux_wc_register_post_statuses' ); 255 256 add_filter( 'woocommerce_reports_order_statuses', 'bux_include_custom_order_status_to_reports', 20, 1 );257 258 function bux_include_custom_order_status_to_reports( $statuses ){259 260 return array( 'pre-shipping', 'pre-transit', 'in-transit', 'paid-bux', 'delivered', 'completed' );261 }262 259 263 260 /* … … 306 303 function bux_wc_add_order_statuses( $order_statuses ) { 307 304 $order_statuses['wc-pending-bux'] = _x( 'Pending Bux Payment', 'WooCommerce Order status', 'text_domain' ); 308 $order_statuses['wc-pre-shipping'] = _x( 'Pre Shipping', 'WooCommerce Order status', 'text_domain' );309 $order_statuses['wc-pre-transit'] = _x( 'Pre Transit', 'WooCommerce Order status', 'text_domain' );310 $order_statuses['wc-in-transit'] = _x( 'In Transit', 'WooCommerce Order status', 'text_domain' );311 $order_statuses['wc-delivered'] = _x( 'Delivered', 'WooCommerce Order status', 'text_domain' );312 $order_statuses['wc-paid-bux'] = _x( 'Paid via Bux', 'WooCommerce Order status', 'text_domain' );313 305 return $order_statuses; 314 306 } -
bux-woocommerce/trunk/readme.txt
r2503114 r2526845 10 10 Requires PHP: 5.2.4 11 11 Stable tag: 1.1.2 12 Version: 1.1. 212 Version: 1.1.3 13 13 Donate link: https://bux.ph/ 14 14 … … 65 65 * Mobile View Thank you page 66 66 67 = 1.1.3 = 68 * Restock on expired notification from bux 69 67 70 == Upgrade Notice == 68 71 … … 88 91 * Mobile View Thank you page 89 92 93 = 1.1.3 = 94 * Restock on expired notification from bux 95 90 96 == Screenshots == 91 97
Note: See TracChangeset
for help on using the changeset viewer.