Is it bad practice to mess with a protected function get_paypal_args?
-
Hi Folks,
I’m starting to get the hang of working with child themes, but have yet to deal with ‘protected’ functions. The function I’m referring to in this case is in the class-wc-gateway-paypal-request.php file in woocommerce.
I was going to try and do something fairly simple, but wanted to makes ure it wasn’t going to screw up something. I wanted to make a slight change to the custom fields that were being transmitted. Here’s the function as it stands now:
protected function get_paypal_args( $order ) {... 'custom' => json_encode( array( 'order_id' => $order->id, 'order_key' => $order->order_key ) ), ...}
My plan is to copy the entire protected function over to my functions.php file, and make a small change to the ‘custom’ field listed above. Here’s what I’m planning on doing:
protected function get_paypal_args( $order ) {... 'custom' => json_encode( array( 'order_id' => $order->id, 'order_key' => $order->order_key, 'rider_id' => $billing->fundraiser ) ), ...}
For whatever reason, I’ve never been able to wrap my mind around the arrows…it’s like they’re there just to confuse me. I mean, isn’t $order->id the same as $order[‘id’]? It makes me question whether the $billing->fundraiser is calling the correct field.
For reference, here is the custom field I created specifically to track the fundraiser on all purchases through woocommerce:
$fields['billing']['fundraiser'] = array( 'label' => __('Fundraiser', 'woocommerce'), 'placeholder' => _x('fundraiser', 'placeholder', 'woocommerce'), 'required' => true, 'class' => array('form-row-wide'), 'type' => 'select', 'options' => $participants ); return $fields;
The fundraiser field displays correctly. I just want the fundraiser custom field information included in the paypal IPN’s so I can update my own databases and track rider fundraising activities.
If I’m doing this wrong, I really appreciate any advice ??
- The topic ‘Is it bad practice to mess with a protected function get_paypal_args?’ is closed to new replies.