program development

The ecshop product details page displays 4 recommended products in the same category

First of all, let's talk about how to display recommended products on the ecshop product detail page. Step 1: Modify the goods.php program file and find the following line […]

article directories

First of all, let's talk about how to display recommended products on the ecshop product detail page

Step 1: Modify the goods.php program file

Find the following line of code $smart->assign ('goods_rank', get_goods_rank($goods_id)); //the sales ranking of the product

Then add two lines under this line of code: $children = get_children($goods['cat_id']);
$smarty->assign(‘best_goods’, get_category_recommend_goods(‘best’, $children));

Step 2: Modify the template file/themes/default/goods.dwt
Add a line of code <where you want to add the similar recommended product!– #BeginLibraryItem “/library/recommend_best.lbi” –><!– #EndLibraryItem –>

After making changes in this way (remember to clear the cache in the background), you can see the "boutique recommendations" on the product page.

But the default only displays a maximum of 3,
The reason is that "recommended quantity of boutique products on the product details page" is not recorded in the data table: ecs_template, so the default value of 3 will be taken.

Then, we can display 5 or more by modifying the default values.
If you want to display more than 3, proceed with the modifications in step 3.

Step 3: Open the includes/lib_main.php file

Find the following line of code $num = isset($static_page_libs[$template][$lib]) ? $static_page_libs[$template][$lib] : 3;

Change it to $num = isset($static_page_libs[$template][$lib]) ? $static_page_libs[$template][$lib] : 4;
Then, go to the background to clear the cache and see if 4 are displayed.? That's about it. If there is anything else you don't understand, you can add me to a detailed chat on QQ.