drtppp75155 2018-08-25 16:23
浏览 65
已采纳

prestashop 1.7 ps_emailalerts和一个外部模块

FIRST OF ALL: Sorry for my not-good english. If something is not understandable let me know, and I will try to explain it better!

Good evening, I am having some issues with prestashop 1.7 and an external module.

I bought a module to add a fee on cash on delivery, this module got some e-mail variables, like {total_fee} or {total_fee_tax}. It takes this values from database, table ps_orders, values "codfee" and "codfeetax".

In standard mails (located in /themes/themename/mails/it/) the variables works properly, but with the e-mail alerts module (/modules/ps_emailalerts) that variables does NOT work at all.

I ask to the developer if he could help me and he sent me 2 functions to include in /modules/ps_emailalerts/ps_emailalerts.php

public static function getCodFeeByOrderID($id_order)
        {
        return Db::getInstance()->getRow('SELECT id_currency, codfee FROM ' . _DB_PREFIX_ . 'orders WHERE id_order = ' . $id_order);
        }

public static function getCodFeeTaxByOrderID($id_order)
        {
        return Db::getInstance()->getRow('SELECT id_currency, codfeetax FROM ' . _DB_PREFIX_ . 'orders WHERE id_order = ' . $id_order);
        }

and these 2 variables in the same file

        '{total_fee}' => $this->getCodFeeByOrderID((int)$params['order']->id),
        '{total_fee_tax}' => $this->getCodFeeTaxByOrderID((int)$params['order']->id),

But unfortunately, something don't work properly! Testing it I see that both variables give the same result "1" instead of the expected "€4" for {total_fee} and "€0.88" for {total_fee_tax}

What's wrong? I hope that somebody help me

  • 写回答

3条回答 默认 最新

  • dongyong6428 2018-08-26 14:33
    关注

    first of all, you should consider overriding the ps_emailalerts module class to add the functions and keep a clean native module: http://build.prestashop.com/howtos/module/how-to-override-modules/.

    Your problem is that getRow() function returns an array in which the keys are the fields fetched (id_currency and codfee(tax)), not the final value you're expecting. You have to use these values to calculate/convert the final amount you want, either in each of the function or after calling it. If you just have one currency on your store, you can change the getRow() function by getValue() and removing the id_currency field retrieval. It's still better to check the return value of the function (false if query failed), and make all the needed validation (currency matching between the one of the order and the one you want to display the information, ...).

    Good luck

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度