The MemberOrder
object in Paid Memberships Pro is crucial for managing membership orders, payments, and related functionalities. It encompasses various properties and methods that facilitate effective handling of orders within the PMPro environment.
- Type: Integer
- Description: Unique identifier for the order.
- Type: String
- Description: A unique code for the order, typically used for referencing and tracking.
- Type: String
- Description: Session ID associated with the order, useful for tracking user sessions.
- Type: Integer
- Description: The ID of the user associated with the order.
- Type: Integer
- Description: The ID of the membership level associated with the order.
- Type: Float
- Description: The subtotal amount for the order.
- Type: Float
- Description: Tax amount applied to the order.
- Type: Float
- Description: The amount discounted by any applied coupon.
- Type: Float
- Description: The total amount for the order.
- Type: String
- Description: The type of payment used (e.g., credit card, PayPal).
- Type: String
- Description: The current status of the order (e.g., 'success', 'pending', 'failed').
- Type: String
- Description: The payment gateway used for the order (e.g., 'stripe', 'paypal').
- Type: String
- Description: Indicates the environment of the gateway (e.g., 'sandbox', 'live').
- Type: DateTime
- Description: The date and time when the order was created.
- Description: Retrieves an order by its ID.
- Parameters:
id
(Integer) - The ID of the order. - Returns: MemberOrder object
- Description: Retrieves an order by its unique code.
- Parameters:
code
(String) - The unique code of the order. - Returns: MemberOrder object
- Description: Saves the current state of the MemberOrder object to the database.
- Returns: Boolean - True on success, false on failure.
- Description: Deletes the order from the database.
- Returns: Boolean - True on successful deletion, false on failure.
- Description: Updates the status of the order.
- Parameters:
status
(String) - The new status to set for the order. - Returns: Boolean - True on successful update, false on failure.
$order = new MemberOrder();
$order->user_id = get_current_user_id();
$order->membership_id = $membership_id;
$order->subtotal = $subtotal;
$order->total = $total;
$order->saveOrder();