OpenCart 2.0.3.1版本商品页“撰写评论”按钮失效问题求助
Hey there, let's tackle this frustrating issue with your old OpenCart store. I’ve seen this exact problem pop up with 2.0.3.1 a few times, so here are the most common fixes to get your review button working again:
First, verify the button's frontend link
Right-click the "撰写评论" button and select "Inspect" to check the<a>tag'shrefattribute. It should look something likeindex.php?route=product/product/write&product_id=XX(where XX is your product's ID). If the link is empty or malformed, head to your theme's product template file:catalog/view/theme/[your-theme]/template/product/product.tpl
Find the button code (usually looks like this):<a href="<?php echo $review; ?>" class="button"><?php echo $button_write_review; ?></a>Make sure the
$reviewvariable is being output correctly. If it’s missing, the controller isn’t passing the right value.Check the product controller for missing variable assignment
Opencatalog/controller/product/product.phpand look for this line (it should be in the main product logic section):$data['review'] = $this->url->link('product/product/write', 'product_id=' . $this->request->get['product_id']);If this line is missing or has typos (like misspelling
writeorproduct_id), add/correct it, then clear your store’s cache.Validate SEO URL settings (if enabled)
If you’re using SEO URLs, broken routing could be the culprit. Go to your admin panel:System > Settings > Edit Store > Serverand confirm "SEO URL" is turned on. Also, double-check your.htaccessfile has the default OpenCart SEO rules (no custom rules that might block theproduct/product/writeroute).Clear all caches
OpenCart 2.x caches template and controller data aggressively. Go toSystem > Settings > Edit Store > Serverand click "Clear Cache". Also, clear your browser’s cache and cookies—old cached links can stick around even after you fix the code.Rule out third-party plugin conflicts
If you’ve installed any product-page or review-related plugins, they might be overriding the button’s link. Temporarily disable all non-core plugins, then test the button. If it starts working, re-enable plugins one by one to find the culprit.Check guest user permissions
Make sure unregistered users can access the review page. Go toSystem > Users > User Groups, edit the "Guest" group, and verify theproduct/product/writeroute is checked under "Access Permissions".
If none of these steps resolve the issue, share snippets from your product.tpl and product.php files, and I can help dig deeper into the problem.
内容的提问来源于stack exchange,提问作者NoobProgrammer

