jdlev
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Invoice pay link’s not working…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
In reply to: [WooCommerce] Invoice pay link’s not workingNobody 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…
Wow…great support. 3 days and no responses. I’m sooooo glad I bought the pro version ::rolleyes::
…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?
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 🙂
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 🙂
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))))); }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?
I’ll give it a shot. Thanks again Mike and Caleb 🙂
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.
Perfect. I’ll check it out. Thanks for the quick response Caleb! 🙂
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
In reply to: [WooCommerce] Woocommerce – Add Action That Fires When Payment Processed?Will Do…thanks again Mr. Jolley 🙂
Forum: Plugins
In reply to: [WooCommerce] Woocommerce – Add Action That Fires When Payment Processed?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
In reply to: [WooCommerce] Woocommerce – Add Action That Fires When Payment Processed?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)?