• Hi , Let me explain what i want to do with EDD_Fees Class :
    I’m trying to use EDD_Fees Class for adding extra fee to price of a product and specially just for that product ( I mean add fee for specific product ID )

    So in EDD docs for EDD_Fees Class I’m not found any tips for this stuff
    Please help me to finding a way to write the right code.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @negarehgfx

    Below is the code with arguments which you can use on appropriate place to add FEE.

    $fee = array(
    	'amount'      => 0,	// Fee Amount
    	'label'       => '',	// Fee Label
    	'id'          => '',	// Fee ID
    	'no_tax'      => false,	// If tax on Fee
    	'type'        => 'fee',	// Type
    	'download_id' => 0,	// Product ID
    	'price_id'    => NULL	// On Specific Product Price ID
    );
    
    EDD()->fees->add_fee( $fee );
    Thread Starter TheXrion

    (@negarehgfx)

    Thanks.

    • This reply was modified 4 years, 7 months ago by TheXrion.
    Thread Starter TheXrion

    (@negarehgfx)

    there is a problem i have faced with , When Additonal service price added to cart the id returns null and i cant remove it from checkout with using remove_fee() function.

    So i have tried to add Fee id manually (tried both character and integer like : 123 or abc ) for check if it get fix but fee doesn’t even added to checkout after using fee id in manually way!

    So question is why Fee ID returns null after echoand var_dump gives boolan(false)?

    This is my Whole function :

    `function myfunction() {
    
    			$feeTitle = 'Example Additonal Service';
    			$feeid_gen = chr(rand(97,122)) . chr(rand(65,90)) . chr(rand(97,122)) . chr(rand(65,90)) . chr(rand(97,122)) . chr(rand(65,90)) . chr(rand(97,122)) . chr(rand(97,122)) . chr(rand(65,90));
    			
    
    			// Check If This Product has Additonal Price by checking is>0
    			// If yes The function will run
    			$gt_metakey = get_post_meta( get_the_ID(), 'my_meta_key');
    			$int_val = (int)$gt_metakey[0];
    
    			// Additional Services Price START here
    					$fee = array(
    			'amount'      => $int_val,	// Fee Amount
    			'label'       => $feeTitle,	// Fee Label
    			'id'          => $feeid_gen,	// Fee ID
    			'no_tax'      => false,	// If tax on Fee
    			'type'        => 'fee',	// Type
    			'download_id' => $download_id,	// Product ID
    			'price_id'    => NULL	// On Specific Product Price ID
    				);
    			EDD()->fees->add_fee( $fee );
    			/// Additional Services Price END here
    				}
    				add_action( 'init', 'myfunction' );

    `

    Hi @negarehgfx

    First of all try to print the whole FEE array with this method get_fee('all')

    So you will get FEE array with Key => Values. Now you can see your added FEE with proper key.

    Use that key to remove the FEE. Actually EDD sanitize the key with sanitize_key function so I have doubt in this.

    Please try to print all array then you will be more cleared in this.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘how using array in EDD_Fees Class’ is closed to new replies.