The parsing function add_filter() in wordpress?

There is such a function:
function insert_order(){
 global $wpdb;
 if(is_admin()): $order_status = 4;
 else: $order_status = $this->order_status;
endif;
 $args = apply_filters('evpl_pre_insert_order', array(
 'user_data' => $this->user_data,
 'order_price' => $this->cart->price,
 'place_amount' => $this->cart->amount,
 'order_details' => serialize($this->details),
 'order_date' => current_time('mysql'),
 'order_status' => $order_status,
 'order_hash' => md5(current_time('mysql'))
));
 $result = $wpdb->insert(
WP_PREFIX.'evpl_orders',
$args
);
if(!$result)
 return false;
 return $wpdb->insert_id;
 }

And
$percent = get_post_meta( $post_id, 'collection', true );

This line makes the sample dB table collection
You need to insert $percent at the line in the function to get this: 'order_price' => $this->cart->price*$percent just paste does not work gives an error, it should be through the function of add_filter(), but how to do not understand, was climbing the entire Internet, wrote a lot, no one helped.
March 12th 20 at 08:02
1 answer
March 12th 20 at 08:04
addfilter('evpl_pre_insert_order', 'my_evpl_pre_insert_order');
my_evpl_pre_insert_order function($data){
 $post = get_post();
 $id = $post->ID;
 $percent = get_post_meta( $id, 'collection', true );
 $data['order_price'] = $data['order_price'] * $percent;

return $data;
}
Unfortunately the website is unable to process this request. - Greta_Carro commented on March 12th 20 at 08:07
comment out the query in the database and print the $args variable print and see what You have there. - desiree.Colli commented on March 12th 20 at 08:10
@desiree.Colli, Problem solved, it's different at all needed, thank you. - Greta_Carro commented on March 12th 20 at 08:13

Find more questions by tags WordPress