PayplansOrder object allows you to perform lots of actions without writing a single query on Order entity.
Get subscription of an order
public function getSubscription()
Return the PayPlans subscription instance related to current order.
Create Invoice for an Order
public function createInvoice()
Returns the instance of invoice created.
Get Invoice of an Order
public function getInvoice($counter = null)
param $counter= Represent the Invoice no.
Return the invoice that is mentioned in the counter.For eg:-If $counter =3,then it will return 3rd number invoice of an order.If $counter is not mentioned then it will return all the invoices of that order.
public function getInvoices($status = null)
param $status:-Represents the status of invoice.It can be Paid,Confirmed or refunded.
Return the invoice according to the status.If status is NULL,then return all the invoices of current order.
Get/Set Buyer of an Order
public function getBuyer($requireinstance=false)
param $requireinstance:- Can be true or False
Return the instance of user,who has currently subscribed the plan.If $requireinstance is 'true' then it will return instance of buyer else return only the id of the buyer.
public function setBuyer($userId=0)
param $userId:- Id of the user.
Set the id of buyer to userId and return current object.
Get Expiration of Plan Type
public function getExpiration($for = PAYPLANS_SUBSCRIPTION_FIXED )
param $for=Type whose expiration time is required. Type can be Fixed, Forever, Recurring, Recurring+1Trial or Recurring+2 trial.
Return the duration after which subscription of plan will expire.
Get Plan for an Order
public function getPlans($requireInstance = false)
param $requireInstance:- Can be true or false
If $requireInstance is true,return the instance of plan, else return the plan id.
Get price for Subscribed Plan
public function getPrice($type = PAYPLANS_SUBSCRIPTION_FIXED)
param $type:-if type is not set then return the regular/normal price
If it is set to RECURRING_TRIAL_1 then return first trial price
If it is set to RECURRING_TRIAL_2 then return second trial price
returns the price of subscription.
Get the type of Plan
public function isRecurring()
return whether plan is of recurring type or not.
If returns- PAYPLANS_RECURRING, then it implies payplan recurring,
PAYPLANS_RECURRING_TRIAL_1, then it implies payplan recurring with trial 1,
PAYPLANS_RECURRING_TRIAL_2, then it implies payplan recurring with trial 2.
If return False,then the subscribed plan is not of recurring type.
Get the Recurrence count
public function getRecurrenceCount()
Return the number of payment user will pay for the subscribed plan.
Refresh current object
public function refresh()
Refresh the current object.For eg. If the current status of the order is 'Order-confirmed'.After some processing,if the status is changed,and if it is not reflected in the object,then by using this function,it will be reflected.
Refund an order
public function refund()
Mark the Order status hold and return the order instance.
Renew subscribed plan
param $expiration:-date till the subscription need to be renewed.
Renew the subscription of order till the date as mentioned in $expiration.
Get/Set status information
public function getStatus()
Return status of order.
public function getStatusName($version='')
Return the name of the status.
public function setStatus($status)
param $status:-status of Order to be set.
Set the status of Order.
Get Total Order Cost
public function getTotal()
Return the invoice amount after applying tax and discount.
Get created date of Order
public function getCreatedDate()
Return date on which Order was created.
public function getCurrency($format = null)
param $format= Show currency format. It can be ISO code, Symbol or Fullname.
Return the currency depending upon the format i.e passed as parameter.
Load invoice of an Order
protected function _loadInvoices($order_id)
param $order_id:-Id of order.
Return all the Invoices related to the order_id(passed as parameter).
Load subscription of plan
protected function _loadSubscription($order_id)
param $order_id:-Id of order.
Return all subscription records of order_id(passed as parameter).
Create empty invoice of an Order
protected function createEmptyInvoice()
Create an empty invoice when no subscription for an order exist and returns the instance of empty invoice.
onPayplansOrderAfterSave is triggered after the order gets saved. It has two parameters viz. $previous and $current. $previous store the previous state of order and $store stores current state of order.
For example, If you want to send email to user after change in order status, then this plugin can be used.
- public function onPayplansOrderAfterSave($prev, $new)
- //send e-mail based on the previous and new status of order.
- return $this->_triggerEmail($prev,$new);
This event is used to perform action after deletion of an order.For example, After deleting the order, deleting all the subscription and invoices related to that order work can be done under this event .
- public function onPayplansOrderBeforeDelete($order)
- $subscription = $order->getSubscription();
- $invoices = $order->getInvoices();
- // delete all the subscriptions linked with this order
- foreach ($invoices as $invoice)
- return true;