Code Duplication    Length = 21-22 lines in 2 locations

includes/api/class-wc-rest-orders-controller.php 1 location

@@ 665-685 (lines=21) @@
662
				throw new WC_REST_Exception( 'woocommerce_rest_cannot_create_shipping', __( 'Cannot create shipping method, try again.', 'woocommerce' ), 500 );
663
			}
664
665
		} else {
666
			$shipping_args = array();
667
668
			if ( isset( $shipping['method_id'] ) ) {
669
				$shipping_args['method_id'] = $shipping['method_id'];
670
			}
671
672
			if ( isset( $shipping['method_title'] ) ) {
673
				$shipping_args['method_title'] = $shipping['method_title'];
674
			}
675
676
			if ( isset( $shipping['total'] ) ) {
677
				$shipping_args['cost'] = floatval( $shipping['total'] );
678
			}
679
680
			$shipping_id = $order->update_shipping( $shipping['id'], $shipping_args );
681
682
			if ( ! $shipping_id ) {
683
				throw new WC_REST_Exception( 'woocommerce_rest_cannot_update_shipping', __( 'Cannot update shipping method, try again.', 'woocommerce' ), 500 );
684
			}
685
		}
686
	}
687
688
	/**

includes/cli/class-wc-cli-order.php 1 location

@@ 1096-1117 (lines=22) @@
1093
				throw new WC_CLI_Exception( 'woocommerce_cannot_create_shipping', __( 'Cannot create shipping method, try again', 'woocommerce' ) );
1094
			}
1095
1096
		} else {
1097
1098
			$shipping_args = array();
1099
1100
			if ( isset( $shipping['method_id'] ) ) {
1101
				$shipping_args['method_id'] = $shipping['method_id'];
1102
			}
1103
1104
			if ( isset( $shipping['method_title'] ) ) {
1105
				$shipping_args['method_title'] = $shipping['method_title'];
1106
			}
1107
1108
			if ( isset( $shipping['total'] ) ) {
1109
				$shipping_args['cost'] = floatval( $shipping['total'] );
1110
			}
1111
1112
			$shipping_id = $order->update_shipping( $shipping['id'], $shipping_args );
1113
1114
			if ( ! $shipping_id ) {
1115
				throw new WC_CLI_Exception( 'woocommerce_cannot_update_shipping', __( 'Cannot update shipping method, try again', 'woocommerce' ) );
1116
			}
1117
		}
1118
	}
1119
1120
	/**