最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Integer in Array returns null

programmeradmin7浏览0评论

Im using EDD_Fees class for adding extra fee to products, Iv’e used this class before and it works like charm but now i can’t figure it out why amount equals to 0 (it seems returning null) But when i echo shows the integer value. Here is my full class code

$feeid_gen = date("Ydhis") . $download_id;
            function cencored_function() {
            // Additional Services Price START here
                    $cencored_fee = array(
            'amount'      => $int_val,
            'label'       => 'hbbl',    
            'id'          => $feeid_gen,    
            'no_tax'      => false,
            'type'        => 'fee',
            'download_id' => $download_id,
            'price_id'    => NULL   
                );
            EDD()->fees->add_fee( $cencored_fee);
            /// Additional Services Price END here
            }
            add_action( 'init', 'cencored_function' );
            cencored_function(); // Runned

Im using EDD_Fees class for adding extra fee to products, Iv’e used this class before and it works like charm but now i can’t figure it out why amount equals to 0 (it seems returning null) But when i echo shows the integer value. Here is my full class code

$feeid_gen = date("Ydhis") . $download_id;
            function cencored_function() {
            // Additional Services Price START here
                    $cencored_fee = array(
            'amount'      => $int_val,
            'label'       => 'hbbl',    
            'id'          => $feeid_gen,    
            'no_tax'      => false,
            'type'        => 'fee',
            'download_id' => $download_id,
            'price_id'    => NULL   
                );
            EDD()->fees->add_fee( $cencored_fee);
            /// Additional Services Price END here
            }
            add_action( 'init', 'cencored_function' );
            cencored_function(); // Runned

Share Improve this question edited May 5, 2020 at 20:49 vancoder 7,92428 silver badges35 bronze badges asked May 5, 2020 at 13:51 TheXrionTheXrion 57 bronze badges 2
  • "But when i echo shows the integer value." — If you're echoing to debug, use var_dump() instead, as that will show you the variable's type as well as its value. – Pat J Commented May 5, 2020 at 14:03
  • @PatJ it shows int(199) :| – TheXrion Commented May 5, 2020 at 14:16
Add a comment  | 

1 Answer 1

Reset to default 1

I can't see where "$int_val" is defined, may be it is defined outside the scope of "cencored_function", it won't work if this is the case.

发布评论

评论列表(0)

  1. 暂无评论