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

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

1 Answer 1

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.

1
  • Oh how its possible i didn't notice that, ThankYou
    – TheXrion
    Commented May 5, 2020 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.