Opencart Recurring Profiles allow the admin to set up subscription-based products in which a customer places an order only once and is charged regularly based on the subscription frequency. It can also be used for setting up the installment payment schemes. The recurring payments are available for daily, weekly, monthly, semi-monthly or yearly. Admin can set up the recurring profile for each frequency from the back end of the Opencart. After setting up the recurring profiles, you can assign it to the product.
Set up a Recurring Profile from the back end
From Catalog -> Recurring Profiles, the admin can view and manage the recurring profiles.
Add – To create a new recurring profile click the Add New button and the following options will appear for adding a new recurring profile:
Name – This will be the name of the subscription or payment plan.
Recurring Profile
Price – This is the price of the subscription plan.
Duration – This field is used for the number of times you would like to charge the customer. For unlimited set it to 0 (zero). If unlimited, the customer will be charged for the subscription plan until the plan will be canceled by the admin or the customer.
Cycle – This is the number that will be applied to your frequency option.
Frequency – This option allows the admin to choose how often the customer will make a payment.For example, the cycle is “1,” and the frequency is “year,” causing the customer to be billed yearly.
Status – Select status to enable or disable the recurring profile.
Trial Profile
Trial price – This is the price of the subscription plan during the trial period.
Trial duration – This field is used for the number of times you would like to charge the customer before the trial expires.
Trial cycle – The number that will be applied to your trial frequency option.
Trial frequency – This option allows the admin to choose how often the customer will make a payment during the trial period.
Trial status – Select status to enable or disable the trial profile
Sort order – Here you can set the order of this recurring profile.
Assign a Recurring Profile to Product
To assign the recurring profile to a product. Navigate to Catalog->Products, select an existing product and click Edit. Click the Recurring tab and select the recurring profile.
User front end view
The customer can select the recurring payment options under Payment Profile. Details about the selected recurring profile including Trial are also visible. After selecting the preferred payment profile, click the Add to Cart button to do the checkout process.
The customer can view the recurring order by navigating to Recurring Payments and the admin can view the recurring order by navigating to Sales->Recurring Orders.
In Opencart at the product page, Add To Cart button fire the onclick event which calls the add method of the catalog/controller/checkout/cart.php file to add the recurring profile to the cart.
if (isset($this->request->post['recurring_id'])) { $recurring_id = $this->request->post['recurring_id']; } else { $recurring_id = 0; } $recurrings = $this->model_catalog_product->getProfiles($product_info['product_id']); if ($recurrings) { $recurring_ids = array(); foreach ($recurrings as $recurring) { $recurring_ids[] = $recurring['recurring_id']; } if (!in_array($recurring_id, $recurring_ids)) { $json['error']['recurring'] = $this->language->get('error_recurring_required'); } } if (!$json) { $this->cart->add($this->request->post['product_id'], $quantity, $option, $recurring_id);
At the checkout page in catalog/controller/checkout/payment_method.php file, the following code is used to check that the product is having the recurring profile or not. If the product has the recurring profile then the payment methods which can handle recurring payment will be displayed to the customer.
$method = $this->{'model_extension_payment_' . $result['code']}->getMethod($this->session->data['payment_address'], $total); if ($method) { if ($recurring) { if (property_exists($this->{'model_extension_payment_' . $result['code']}, 'recurringPayments') && $this->{'model_extension_payment_' . $result['code']}->recurringPayments()) { $method_data[$result['code']] = $method; } } else { $method_data[$result['code']] = $method; } }
Be the first to comment.