Allows to set custom order_key while creating an order
This commit is contained in:
parent
4750a2d567
commit
ea19190d3b
|
@ -71,7 +71,7 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
|
|||
'ping_status' => 'closed',
|
||||
'post_author' => 1,
|
||||
'post_title' => $this->get_post_title(),
|
||||
'post_password' => wc_generate_order_key(),
|
||||
'post_password' => $this->get_order_key( $order ),
|
||||
'post_parent' => $order->get_parent_id( 'edit' ),
|
||||
'post_excerpt' => $this->get_post_excerpt( $order ),
|
||||
)
|
||||
|
@ -264,6 +264,17 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
|
|||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
|
||||
/**
|
||||
* Get order key.
|
||||
*
|
||||
* @since 4.3.0
|
||||
* @param WC_order $order Order object.
|
||||
* @return string
|
||||
*/
|
||||
protected function get_order_key( $order ) {
|
||||
return wc_generate_order_key();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read order data. Can be overridden by child classes to load other props.
|
||||
*
|
||||
|
|
|
@ -81,7 +81,9 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement
|
|||
* @param WC_Order $order Order object.
|
||||
*/
|
||||
public function create( &$order ) {
|
||||
$order->set_order_key( wc_generate_order_key() );
|
||||
if ( '' === $order->get_order_key() ) {
|
||||
$order->set_order_key( wc_generate_order_key() );
|
||||
}
|
||||
parent::create( $order );
|
||||
do_action( 'woocommerce_new_order', $order->get_id(), $order );
|
||||
}
|
||||
|
@ -302,6 +304,21 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement
|
|||
return $order->get_customer_note();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get order key.
|
||||
*
|
||||
* @since 4.3.0
|
||||
* @param WC_order $order Order object.
|
||||
* @return string
|
||||
*/
|
||||
protected function get_order_key( $order ) {
|
||||
if ( '' !== $order->get_order_key() ) {
|
||||
return $order->get_order_key();
|
||||
}
|
||||
|
||||
return parent::get_order_key( $order );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get amount already refunded.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue