Title: jdlev's Replies | WordPress.org

---

# jdlev

  [  ](https://wordpress.org/support/users/jdlev/)

 *   [Profile](https://wordpress.org/support/users/jdlev/)
 *   [Topics Started](https://wordpress.org/support/users/jdlev/topics/)
 *   [Replies Created](https://wordpress.org/support/users/jdlev/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/jdlev/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/jdlev/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/jdlev/engagements/)
 *   [Favorites](https://wordpress.org/support/users/jdlev/favorites/)

 Search replies:

## Forum Replies Created

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/users/jdlev/replies/page/2/?output_format=md)
[→](https://wordpress.org/support/users/jdlev/replies/page/2/?output_format=md)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Invoice pay link’s not working](https://wordpress.org/support/topic/please-help-invoice-pay-links-not-working/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/please-help-invoice-pay-links-not-working/#post-9572114)
 * …and I did want to mention I followed the sticky recommendations on the forum
   to try to display any php errors that might be occurring, but so far I haven’t
   seen any error codes. 🙁
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Invoice pay link’s not working](https://wordpress.org/support/topic/please-help-invoice-pay-links-not-working/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/please-help-invoice-pay-links-not-working/#post-9571749)
 * Nobody else has dealt with this same issue? I hate to nag, but could really use
   some help with this issue and I have no idea where to start…
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Elementor Website Builder - more than just a page builder] Help customizing user interface / dashboard?](https://wordpress.org/support/topic/help-customizing-user-interface-dashboard/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/help-customizing-user-interface-dashboard/#post-9389701)
 * Wow…great support. 3 days and no responses. I’m sooooo glad I bought the pro 
   version ::rolleyes::
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Is it bad practice to mess with a protected function get_paypal_args?](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [10 years ago](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/#post-7478825)
 * …and the trek continues 🙂 So Mike, I think I have a handle on what the filter
   does, but the function’s variables are throwing me for a loop (Ha! ‘loop’…that’s
   a wp joke! :D)
 * If I understand add_filter correctly, add_filter acts on a preexisting hook titled‘
   woocommerce_paypal_args’. The jdlev_woocommerce_paypal_args is just the name 
   of the custom function to use to act on the information in the w_p_a hook. 10
   is the priority and 2 is the number of arguments to pass into the j_w_p_a function.
   Both the filter and function belong in my functions.php file located in my child
   theme folder. The order that the filter and function are in, in the functions.
   php file doesn’t matter (the code doesn’t execute sequentially is basically what
   I’m asking on the functions.php file)
 * I’ve been trying to read up on the 2 variables you are passing the function, 
   but haven’t been able to find much info. What are the $args and $order variables,
   because I’m not sure if they’re arrays, classes, or objects? Can you send me 
   a link to read up on those items? $order is just such a common phrase I’m having
   trouble finding more information on it.
 * Another thing that I might be wrong about, but don’t you have to return $order
   when you’re done? The only thing I see returned in the example is the $args?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Is it bad practice to mess with a protected function get_paypal_args?](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [10 years ago](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/#post-7478691)
 * Thanks for stickin with me on this Mike, but it’s just not clicking for some 
   reason…probably because I’ve been up all night. Anyways, I appreciate your patience
   because this seems like some pretty basic stuff I should get no problem. I’ll
   give in another go after a little siesta, and let you know how it turned out.
   Thanks again 🙂
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Is it bad practice to mess with a protected function get_paypal_args?](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [10 years ago](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/#post-7478672)
 * I’ve been working to understand the example Caleb put forth…for whatever reason,
   it’s like reading greek to me, but I’ll keep trying.
 * Let me ask you this. I noticed in the example, the add_filter hook is called 
   after the function. Does the order of when the hook & when the function are called
   matter? Also, would I just use array_merge to add the last key-value pair to 
   the array?
 * I’m a bit confused because in the other example, you bring in another array of
   fruit as a parameter of the function. Should I be including the object/class/
   or whatever you call it that represents the paypal args which looks to be….$order?
   Ha! Maybe we’ve come full circle and are back to $order now 🙂
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Is it bad practice to mess with a protected function get_paypal_args?](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [10 years ago](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/#post-7478655)
 * So I tried the following, and haven’t been able to add the variable to the custom
   field. Not sure where I’m going wrong as I tried replacing the $order->fundraiser
   with just a standard string to see if I could get it to at least pass some value,
   and still nothing. Here’s the full code:
 * `add_filter( 'get_paypal_args', 'add_custom_field_element_to_paypal');`
 *     ```
       function add_custom_field_element_to_paypal()
       {
           return apply_filters('woocommerce_paypal_args', array_merge(
               array(
                   'custom' => json_encode(
                       array(
                           'order_id' => $order->id, 'order_key' => $order->order_key, 'fundraiser' => $order->fundraiser)))));
   
       }
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Is it bad practice to mess with a protected function get_paypal_args?](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [10 years ago](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/#post-7478641)
 * Hey mike, one other quick question. What do you call the things like $order? 
   Is that a class that is produced by woocommerce, and all a class is, is a shell
   of sorts for holding variables and functions?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Is it bad practice to mess with a protected function get_paypal_args?](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [10 years ago](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/#post-7478639)
 * I’ll give it a shot. Thanks again Mike and Caleb 🙂
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Is it bad practice to mess with a protected function get_paypal_args?](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [10 years ago](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/#post-7478613)
 * So read the tutorial (great article btw), and it really helped me understand 
   filters better. Here’s the steps I’ve taken so far in my functions file:
 * 1) I added a filter:
    `add_filter( 'get_paypal_args', 'add_custom_field_element_to_paypal');`
 * 2) This is a bit trickier. I added the custom function to my functions.php file,
   but am not sure how to reference the ‘custom’ field since it’s an array within
   an array and has json_encoding. So how should I add another key value pair to
   the array:
 * `'custom' => json_encode( array( 'order_id' => $order->id, 'order_key' => $order-
   >order_key, 'new_key' => $order->new_value ) )`
 * While we’re discussing things…do you have an elementary way to remember the function
   of the -> and => operators? My mind just goes blank whenever I see one of those
   dumb things lol.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Is it bad practice to mess with a protected function get_paypal_args?](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [10 years ago](https://wordpress.org/support/topic/is-it-bad-practice-to-mess-with-a-protected-function-get_paypal_args/#post-7478606)
 * Perfect. I’ll check it out. Thanks for the quick response Caleb! 🙂
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] $40 Reward: Need some help ASAP with meta queries for woocommerce](https://wordpress.org/support/topic/40-reward-need-some-help-asap-with-meta-queries-for-woocommerce/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [10 years ago](https://wordpress.org/support/topic/40-reward-need-some-help-asap-with-meta-queries-for-woocommerce/#post-7464972)
 * To be honest, I didn’t know if it was going to be that complicated or not. I 
   figured it was just a matter of coming up with the specific query.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Woocommerce – Add Action That Fires When Payment Processed?](https://wordpress.org/support/topic/woocommerce-add-action-that-fires-when-payment-processed/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [10 years ago](https://wordpress.org/support/topic/woocommerce-add-action-that-fires-when-payment-processed/#post-7450075)
 * Will Do…thanks again Mr. Jolley 🙂
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Woocommerce – Add Action That Fires When Payment Processed?](https://wordpress.org/support/topic/woocommerce-add-action-that-fires-when-payment-processed/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [10 years ago](https://wordpress.org/support/topic/woocommerce-add-action-that-fires-when-payment-processed/#post-7449842)
 * Actually, I had to use the hook: ‘woocommerce_thankyou_order_received_text’
    
   to have the statement execute after the payment had been received instead of 
   the ‘woocommerce_review_order_after_submit’ I listed above.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Woocommerce – Add Action That Fires When Payment Processed?](https://wordpress.org/support/topic/woocommerce-add-action-that-fires-when-payment-processed/)
 *  Thread Starter [jdlev](https://wordpress.org/support/users/jdlev/)
 * (@jdlev)
 * [10 years ago](https://wordpress.org/support/topic/woocommerce-add-action-that-fires-when-payment-processed/#post-7449832)
 * Update: I think I found a good woocommerce hook to add the action to:
    “woocommerce_review_order_after_payment”….
 * so to add an action to this hook whenever it fires, I’d do something like this:
 * in my functions.php file:
 * add_action(‘woocommerce_review_order_after_payment’, ‘my_wpdb_insert_or_update_function’);
 * function my_wpdb_insert_or_update_function($riderID, $donationAmount) {
    global
   $wpdb; $myQ = $wpdb->prepare(‘Insert INTO my_table (‘rider_id’, ‘funds_raised’)
   VALUES ($riderID, $donationAmount)); $wpdb->query($myQ) or die (“Error Preparing
   Query For Execution”); $wpdb->execute() or die (“Error Sending Data To DB”); 
   $wpdb->close(); }
 * Does that look correct for the most part? Will the $donationAmount and $riderID
   be available via POST data (I can see these variables on the checkout screen)?

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/users/jdlev/replies/page/2/?output_format=md)
[→](https://wordpress.org/support/users/jdlev/replies/page/2/?output_format=md)