You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenCart 2.3.0.2 订阅商品购物车未叠加订阅价问题求助

Fixing Subscription Price Not Updating for $0 Donation Products in 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:06:48