OpenCart 2.3.0.2 订阅商品购物车未叠加订阅价问题求助
Hey Sarah, I’ve tackled this exact issue with OpenCart 2.3.0.2 before—let’s walk through three solid solutions to get your donation subscription product showing the correct price at checkout.
1. Quick Code Fix (For Default Subscription Module)
OpenCart’s default subscription module doesn’t handle $0 base prices gracefully by default. Here’s how to force it to use the selected subscription amount as the product price:
Step 1: Update the Cart Controller
Edit catalog/controller/checkout/cart.php and find the add() method. Right after the line where $product_info is retrieved (around line 40-50), add this code snippet:
// Override price for donation subscription product if ($product_info['subscription'] && isset($this->request->post['subscription_id'])) { $subscription = $this->model_catalog_product->getSubscription($this->request->post['subscription_id']); if ($subscription) { // Replace base $0 price with selected subscription amount $product_info['price'] = $subscription['price']; } }
This tells OpenCart to use the selected subscription price instead of the $0 base price when adding the item to cart.
Step 2: Update Cart Display
To make sure the price shows correctly in the mini-cart and cart page, edit catalog/controller/common/cart.php. Look for the loop that builds cart items, and add this inside the loop (after getting $product):
// Check for subscription price in cart if (!empty($product['subscription_id'])) { $subscription = $this->model_catalog_product->getSubscription($product['subscription_id']); if ($subscription) { $product['price'] = $subscription['price']; $product['total'] = $subscription['price'] * $product['quantity']; } }
Don’t forget to clear your OpenCart cache after making these changes (System > Maintenance > Cache).
2. Use a Donation-Specific Extension
If you’d rather avoid code edits, look for a dedicated donation/subscription extension compatible with OpenCart 2.3.0.2. These extensions are built to handle $0 base prices and dynamic subscription amounts out of the box:
- Custom Donation Product: Lets you set up dropdowns for fixed donation amounts and ties them to subscription billing cycles.
- Subscription Donation Module: Automatically syncs selected subscription prices to the cart total and handles recurring billing.
Make sure to filter extensions by "2.x" compatibility on the OpenCart Marketplace to avoid version conflicts.
3. Simplify with Product Options (No Subscription Module Needed)
If your main goal is to let users select a monthly donation amount (and you don’t need automatic recurring billing), use OpenCart’s built-in Product Options instead:
- Go to your donation product’s Options tab.
- Create a new Option with type
Select. - Add option values like "$10/month" (price: +$10) and "$20/month" (price: +$20).
- Set the product’s base price to $0.
This method works because OpenCart’s option system automatically adds the option price to the base price, so checkout will show the correct total without any extra code. If you still need recurring billing, you can pair this with a subscription module that triggers based on the selected option.
Important Notes
- Always back up your files before modifying core code.
- Test the full checkout flow (including guest checkout) to ensure prices update correctly everywhere.
- If using recurring billing, double-check that your payment gateway supports subscriptions (PayPal Standard, Stripe, etc.).
内容的提问来源于stack exchange,提问作者Sarah C. Corriher

