关于php–在prestashop中定制价格计算的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于ecshop价格计算、php–404PagePrestashopMultistore、php
关于php – 在prestashop中定制价格计算的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于ecshop价格计算、php – 404 Page Prestashop Multistore、php – prestashop 1.7上的Prestashop1.6主题、php – PrestaShop Modules页面加载速度非常慢等相关知识的信息别忘了在本站进行查找喔。
本文目录一览:- php – 在prestashop中定制价格计算
- ecshop价格计算
- php – 404 Page Prestashop Multistore
- php – prestashop 1.7上的Prestashop1.6主题
- php – PrestaShop Modules页面加载速度非常慢
php – 在prestashop中定制价格计算
我的目标是每订单增加10美元,但是PS会按产品数量增加额外的费用,所以如果你订购20个产品,它会要求你200 $而不是10 …
我需要覆盖/classes/Product.PHP中的计算过程,类似于:
if (product_id = 44) { $price = $price + 10; } else { $price = $price }
你有什么想法吗
<?PHP class Product extends ProductCore { // Here we will put every method or property override }
在这个类中,您将复制/粘贴静态方法priceCalculation(在我的原始Product.PHP文件的第2567行).完成后,只需在方法的最后添加这些行,就在self :: $_price [$cache_id] = $price之前; :
if ($id_product == 44 && Context::getContext()->customer->isLogged()) { $customer = Context::getContext()->customer; $nbTimesBoughtThisProduct = (int) Db::getInstance()->getValue(' SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'product` p JOIN `' . _DB_PREFIX_ . 'order_detail` od ON p.`id_product` = od.`product_id` JOIN `' . _DB_PREFIX_ . 'orders` o ON od.`id_order` = o.`id_order` WHERE o.`id_customer` = ' . $customer->id . ' AND p.`id_product` = ' . $id_product . ' '); $price += $nbTimesBoughtThisProduct * 10; }
我没有时间测试这些,但我认为这是做你想要做的方式.
priceCalculation是每次Prestashop需要产品价格的方法.通过将此代码放在此方法的最后,我们修改返回的价格.
代码首先检查客户是否被记录(如果没有,我们不能从他那里获得订单).如果是这样,查询会检索客户过去购买此产品的次数.该数字乘以十,并将该值添加到价格.
编辑:如果,如Cyril Tourist所说,你还要计算当前的购物车,得到这个新的代码(仍然没有测试,但应该工作):
if ($id_product == 44 && Context::getContext()->customer->isLogged()) { $customer = Context::getContext()->customer; $nbTimesBoughtThisProduct = (int) Db::getInstance()->getValue(' SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'product` p JOIN `' . _DB_PREFIX_ . 'order_detail` od ON p.`id_product` = od.`product_id` JOIN `' . _DB_PREFIX_ . 'orders` o ON od.`id_order` = o.`id_order` WHERE o.`id_customer` = ' . $customer->id . ' AND p.`id_product` = ' . $id_product . ' '); $productsInCart = Context::getContext()->cart->getProducts(); foreach ($productsInCart as $productInCart) { if ($productInCart['id_product'] == 44) { $nbTimesBoughtThisProduct++; } } $price += $nbTimesBoughtThisProduct * 10; }
此外,我建议您将“44”产品ID存储在常量,配置变量或任何东西中,但不保留在代码中.我只是为了这个例子.
ecshop价格计算
我重新更改了ecshop的价格计算功能,但是做好之后发现原来的优惠价格没有算进去,像团购活动,满500有打折都没有算进去,找不到是什么原因,有没有大神做过这样的二次开发,对ecshop价格计算很了解,我想问下有没有这方面的资料或者给点指,现在一点头绪也没,谢啦php – 404 Page Prestashop Multistore
默认店铺地址: http://lak-lak.ir
新的多店地址: http://lak-lak.ir/ghods
似乎在新店的主页上一切都很好,但是对于联系我们,最佳搜索和其他页面的页面,Prestashop显示404错误页面.
怎么解决这个问题?
附:我的商店也启用了URL重写功能.
这是.htaccess文件的内容:
# ~~start~~ Do not remove this comment,Prestashop will keep automatically the code outside this comment when .htaccess will be generated again # .htaccess automaticaly generated by PrestaShop e-commerce open-source solution # http://www.prestashop.com - http://www.prestashop.com/forums <IfModule mod_rewrite.c> <IfModule mod_env.c> SetEnv HTTP_MOD_REWRITE On </IfModule> RewriteEngine on #Domain: lak-lak.ir RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule . - [E=REWRITEBASE:/] RewriteRule ^api$api/ [L] RewriteRule ^api/(.*)$%{ENV:REWRITEBASE}webservice/dispatcher.PHP?url=$1 [QSA,L] # Images RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/c/$1$2.jpg [L] # AlphaimageLoader for IE and fancybox RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$js/jquery/plugins/fancybox/images/$1.$2 [L] #Domain: lak-lak.ir RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule . - [E=REWRITEBASE:/] RewriteRule ^api$api/ [L] RewriteRule ^api/(.*)$%{ENV:REWRITEBASE}webservice/dispatcher.PHP?url=$1 [QSA,L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^ghods$/ghods/ [L,R] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^ghods/(.*) /$1 [L] # Images RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$%{ENV:REWRITEBASE}img/c/$1$2.jpg [L] # AlphaimageLoader for IE and fancybox RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$js/jquery/plugins/fancybox/images/$1.$2 [L] # dispatcher RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^.*$- [NC,L] RewriteCond %{HTTP_HOST} ^lak-lak.ir$ RewriteRule ^.*$%{ENV:REWRITEBASE}index.PHP [NC,L] </IfModule> AddType application/vnd.ms-fontobject .eot AddType font/ttf .ttf AddType font/otf .otf AddType application/x-font-woff .woff <IfModule mod_headers.c> <FilesMatch "\.(ttf|ttc|otf|eot|woff|svg)$"> Header add Access-Control-Allow-Origin "*" </FilesMatch> </IfModule> #If rewrite mod isn't enabled ErrorDocument 404 /index.PHP?controller=404 # ~~end~~ Do not remove this comment,Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
您必须确保在apache服务器中启用了mod重写&在目录中设置AllowOverride all
看看这些主题:
> How to enable mod_rewrite for Apache 2.2
> How to Set AllowOverride all
希望这适合你:)
php – prestashop 1.7上的Prestashop1.6主题
我已经安装了prestashop 1.7并且我喜欢它的管理界面,但是,与prestashop 1.6提供的相比,它的默认主题根本不适合我的活动领域.
这是我的问题,是否可以在prestashop 1.7上使用prestashop 1.6默认主题.
真的,这太酷了.先感谢您.
解决方法
1.7已经改变了很多模板结构和传递给模板的数据.关键是要从模板中删除逻辑和计算,以便更容易地创建主题.
这对团队来说是一个艰难的选择,但我们相信这是能够同时解决这么多问题的唯一方法.
朱利安
php – PrestaShop Modules页面加载速度非常慢
您对如何处理此问题有任何想法吗?
解决方法
关于php – 在prestashop中定制价格计算的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于ecshop价格计算、php – 404 Page Prestashop Multistore、php – prestashop 1.7上的Prestashop1.6主题、php – PrestaShop Modules页面加载速度非常慢等相关内容,可以在本站寻找。
本文标签: