Changeset 3092786
- Timestamp:
- 05/26/2024 07:22:37 PM (23 months ago)
- Location:
- woo-cost-of-shipping
- Files:
-
- 19 added
- 3 edited
-
tags/1.4.2 (added)
-
tags/1.4.2/README.txt (added)
-
tags/1.4.2/assets (added)
-
tags/1.4.2/assets/css (added)
-
tags/1.4.2/assets/css/woocommerce-cost-of-shipping.css (added)
-
tags/1.4.2/assets/js (added)
-
tags/1.4.2/assets/js/index.js (added)
-
tags/1.4.2/assets/js/woocommerce-cost-of-shipping.js (added)
-
tags/1.4.2/includes (added)
-
tags/1.4.2/includes/admin (added)
-
tags/1.4.2/includes/admin/class-wc-cos-admin-orders.php (added)
-
tags/1.4.2/includes/admin/class-wc-cos-admin.php (added)
-
tags/1.4.2/includes/admin/class-wc-cos-safe-domdocument.php (added)
-
tags/1.4.2/languages (added)
-
tags/1.4.2/languages/woocommerce-cost-of-shipping.pot (added)
-
tags/1.4.2/woo-includes (added)
-
tags/1.4.2/woo-includes/class-wc-cos-dependencies.php (added)
-
tags/1.4.2/woo-includes/woo-functions.php (added)
-
tags/1.4.2/woocommerce-cost-of-shipping.php (added)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/includes/admin/class-wc-cos-admin-orders.php (modified) (13 diffs)
-
trunk/woocommerce-cost-of-shipping.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-cost-of-shipping/trunk/README.txt
r3092545 r3092786 3 3 Donate link: https://www.theritesites.com/plugins/woocommerce-cost-of-shipping 4 4 Tags: cost of shipping, shipping cost, WooCommerce, net profit, shipstation 5 Requires at least: 4.8.15 Requires at least: 5.2 6 6 Tested up to: 6.5 7 7 Requires PHP: 7.0 … … 59 59 60 60 == Changelog == 61 62 = 1.5.0 = 63 - WooCommerce High Performance Order Storage (HPOS) update 61 64 62 65 = 1.4.2 = -
woo-cost-of-shipping/trunk/includes/admin/class-wc-cos-admin-orders.php
r2911313 r3092786 27 27 * 28 28 */ 29 use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController; 29 30 30 31 if ( ! defined( 'ABSPATH' ) ) { … … 177 178 /** 178 179 * Callback function for AJAX request to handle the manual shipping cost entry. 179 * This function will return success on successful update_post_meta for the new shipping cost and method.180 * This function will return success on successful $order->update_meta_data for the new shipping cost and method. 180 181 * 181 182 * @since 1.0.0 … … 235 236 do_action( 'wc_cos_before_cost_of_shipping_stored', $order_id, $cos, $method ); 236 237 238 // Query wc_order 239 $order = wc_get_order( $order_id ); 240 237 241 // Store for possible history update before the new store overwrites. 238 $old_cos = get_post_meta( $order_id,'_wc_cost_of_shipping', true );239 $old_method = get_post_meta( $order_id,'_wc_cos_method', true );242 $old_cos = $order->get_meta( '_wc_cost_of_shipping', true ); 243 $old_method = $order->get_meta( '_wc_cos_method', true ); 240 244 241 245 /** … … 245 249 * saved by at this point. Might see some functionality wanted later on, 246 250 * but this will be the simplest way forward to not corrupt data. 251 * 252 * Updated in 1.5.0 for HPOS 247 253 */ 248 $flag = update_post_meta( $order_id, '_wc_cost_of_shipping', ( float ) $cos ); 249 if ( ! $flag ) { 254 if ( ( float ) $old_cos == ( float ) $cos ) { 250 255 if ( true === $this->plugin->__get( 'debug' ) ) { 251 256 $this->log->add( 'the-rite-sites-profit-plugins', __( ' No need to update Cost of Shipping, values are equivalent.', 'woocommerce-cost-of-shipping' ) ); … … 253 258 return false; 254 259 } 255 256 update_post_meta( $order_id, '_wc_cos_method', $method ); 260 $order->update_meta_data( '_wc_cost_of_shipping', ( float ) $cos ); 261 262 $order->update_meta_data( $order_id, '_wc_cos_method', $method ); 257 263 258 264 if ( true === $this->plugin->__get( 'debug' ) ) { … … 261 267 262 268 if ( ! empty( $old_cos ) && ! empty( $old_method ) ) { 263 $cos_history = maybe_unserialize( get_post_meta( $order_id, '_wc_cos_history' ) ); 269 $dirty_cos_history = $order->get_meta( '_wc_cos_history' ); 270 $cos_history = maybe_unserialize( $dirty_cos_history ); 264 271 if ( empty( $cos_history ) ) { 265 272 $cos_history = array(); … … 267 274 268 275 $cos_history[] = array( 'method' => $old_method, 'cos' => $old_cos ); 269 update_post_meta( $order_id,'_wc_cos_history', $cos_history );276 $order->update_meta_data( '_wc_cos_history', $cos_history ); 270 277 271 278 if ( true === $this->plugin->__get( 'debug' ) ) { … … 274 281 } 275 282 283 $order->save(); 276 284 do_action( 'wc_cos_after_cost_of_shipping_stored', $order_id, $cos, $method ); 277 285 return true; … … 342 350 } 343 351 344 $previous_cos_method = get_post_meta( $order_id, '_wc_cos_method', true ); 352 $order = wc_Get_order( $order_id ); 353 $previous_cos_method = $order->get_meta( '_wc_cos_method', true ); 345 354 if ( false === $flag && ! ( 'wc_services' === $previous_cos_method ) ) return false; 346 355 if ( true === $this->store_cost_of_shipping( $order_id, $cost_of_shipping, 'wc_services' ) ) { … … 385 394 */ 386 395 public function display_wcs_cos_meta_box( $post_id ) { 387 $order = wc_get_order( $post_id ); 396 $order = ( $post_or_order_object instanceof WP_Post ) ? wc_get_order( $post_or_order_object->ID ) : $post_or_order_object; 397 // $order = wc_get_order( $post_id ); 388 398 389 399 $cos = floatval( $order->get_meta( '_wc_cost_of_shipping' ) ); … … 451 461 public function add_wcs_cos_meta_box( $post_type, $post ) { 452 462 if ( $this->should_show_wcs_cos_meta_box() ) { 463 464 $screen = class_exists( '\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController' ) && wc_get_container()->get( CustomOrdersTableController::class )->custom_orders_table_usage_is_enabled() 465 ? wc_get_page_screen_id( 'shop-order' ) 466 : 'shop_order'; 467 453 468 add_meta_box( 454 469 'wc-cos-services-cost-of-shipping', 455 470 __( 'Import Cost of Shipping', 'woocommerce-cost-of-shipping' ), 456 471 array( $this, 'display_wcs_cos_meta_box' ), 457 'shop_order',472 $screen, 458 473 'side', 459 474 'default' … … 584 599 585 600 $ajax_nonce = wp_create_nonce( 'edit-shipping-meta-nonce' ); 586 $cost_of_shipping = floatval( get_post_meta( $post_id, '_wc_cost_of_shipping', true ) ); 601 $order = wc_get_order( $post_id ); 602 $cost_of_shipping = floatval( $order->get_meta( '_wc_cost_of_shipping', true ) ); 587 603 $formatted_total = wc_price( $cost_of_shipping ); 588 604 ?> … … 627 643 protected function get_formatted_order_shipping_cost( $order_id ) { 628 644 629 $order_shipping_cost = get_post_meta( $order_id, '_wc_cost_of_shipping', true ); 645 $order = wc_get_order( $order_id ); 646 $order_shipping_cost = $order->get_meta( '_wc_cost_of_shipping', true ); 630 647 $formatted_total = wc_price( $order_shipping_cost ); 631 648 -
woo-cost-of-shipping/trunk/woocommerce-cost-of-shipping.php
r3092545 r3092786 4 4 * Plugin URI: https://www.theritesites.com/plugins/woocommerce-cost-of-shipping 5 5 * Description: Allows the association of the cost of shipping to WooCommerce orders 6 * Version: 1. 4.26 * Version: 1.5.0 7 7 * Author: TheRiteSites 8 8 * Author URI: https://www.theritesites.com … … 13 13 * WC tested up to: 8.9 14 14 * WC requires at least: 3.0 15 * Requires at least: 5.2 15 16 * 16 17 * @link https://www.theritesites.com/plugins/woocommerce-cost-of-shipping 17 18 * 18 19 * @package WC_COS 19 * @version 1. 4.220 * @version 1.5.0 20 21 */ 21 22 … … 25 26 * developed by TheRiteSites and found at https://www.theritesites.com/plugins/woocommerce-net-profit 26 27 * 27 * Copyright (c) 2020,202 2TheRiteSites (email : contact@theritesites.com)28 * Copyright (c) 2020,2024 TheRiteSites (email : contact@theritesites.com) 28 29 * 29 30 * This program is free software; you can redistribute it and/or modify … … 61 62 * @since 1.0.0 62 63 */ 63 const VERSION = '1. 4.2';64 const VERSION = '1.5.0'; 64 65 65 66 /** … … 347 348 register_activation_hook( __FILE__, array( wc_cos(), '_activate' ) ); 348 349 register_deactivation_hook( __FILE__, array( wc_cos(), '_deactivate' ) ); 350 351 add_action( 'before_woocommerce_init', function() { 352 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { 353 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); 354 } 355 } );
Note: See TracChangeset
for help on using the changeset viewer.