Skip to content

Instantly share code, notes, and snippets.

@AnadarProSvcs
Created December 20, 2023 13:48
Show Gist options
  • Save AnadarProSvcs/cd22e890660cb0f60384754d468274cf to your computer and use it in GitHub Desktop.
Save AnadarProSvcs/cd22e890660cb0f60384754d468274cf to your computer and use it in GitHub Desktop.
A breakdown of the Member_Order object properties and methods for Paid Memberships Pro #PMPro #pmpro

PMPro MemberOrder Object Reference

Overview

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.

Properties

1. id

  • Type: Integer
  • Description: Unique identifier for the order.

2. code

  • Type: String
  • Description: A unique code for the order, typically used for referencing and tracking.

3. session_id

  • Type: String
  • Description: Session ID associated with the order, useful for tracking user sessions.

4. user_id

  • Type: Integer
  • Description: The ID of the user associated with the order.

5. membership_id

  • Type: Integer
  • Description: The ID of the membership level associated with the order.

6. subtotal

  • Type: Float
  • Description: The subtotal amount for the order.

7. tax

  • Type: Float
  • Description: Tax amount applied to the order.

8. couponamount

  • Type: Float
  • Description: The amount discounted by any applied coupon.

9. total

  • Type: Float
  • Description: The total amount for the order.

10. payment_type

  • Type: String
  • Description: The type of payment used (e.g., credit card, PayPal).

11. status

  • Type: String
  • Description: The current status of the order (e.g., 'success', 'pending', 'failed').

12. gateway

  • Type: String
  • Description: The payment gateway used for the order (e.g., 'stripe', 'paypal').

13. gateway_environment

  • Type: String
  • Description: Indicates the environment of the gateway (e.g., 'sandbox', 'live').

14. timestamp

  • Type: DateTime
  • Description: The date and time when the order was created.

Methods

1. getMemberOrderByID($id)

  • Description: Retrieves an order by its ID.
  • Parameters: id (Integer) - The ID of the order.
  • Returns: MemberOrder object

2. getMemberOrderByCode($code)

  • Description: Retrieves an order by its unique code.
  • Parameters: code (String) - The unique code of the order.
  • Returns: MemberOrder object

3. saveOrder()

  • Description: Saves the current state of the MemberOrder object to the database.
  • Returns: Boolean - True on success, false on failure.

4. deleteMe()

  • Description: Deletes the order from the database.
  • Returns: Boolean - True on successful deletion, false on failure.

5. updateStatus($status)

  • 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.

Usage Example

$order = new MemberOrder();
$order->user_id = get_current_user_id();
$order->membership_id = $membership_id;
$order->subtotal = $subtotal;
$order->total = $total;
$order->saveOrder();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment