Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'wcfm_init', function() {
- global $WCFMmp;
- if( wcfm_is_vendor() ) {
- if( has_filter( 'wcfmmarketplace_orders_actions', array( $WCFMmp->wcfmmp_refund, 'wcfmmp_refund_orders_actions' ) ) ) {
- remove_filter( 'wcfmmarketplace_orders_actions', array( $WCFMmp->wcfmmp_refund, 'wcfmmp_refund_orders_actions' ), 100 );
- add_filter( 'wcfmmarketplace_orders_actions', 'wcfmmp_refund_orders_actions_modified', 100, 4 );
- }
- }
- }, 12 );
- function wcfmmp_refund_orders_actions_modified( $actions, $vendor_id, $order, $the_order ) {
- global $WCFM, $WCFMmp;
- $order_status = sanitize_title( $the_order->get_status() );
- if( in_array( $order_status, apply_filters( 'wcfm_refund_disable_order_status', array( 'failed', 'cancelled', 'refunded', 'pending', 'on-hold', 'request', 'proposal', 'proposal-sent', 'proposal-expired', 'proposal-rejected', 'proposal-canceled', 'proposal-accepted' ) ) ) ) return $actions;
- if( !apply_filters( 'wcfm_is_allow_refund_requests', true ) ) return $actions;
- if( !apply_filters( 'wcfm_is_allow_paid_order_refund', false ) && ($order->withdraw_status != 'pending') && !in_array( $the_order->get_payment_method(), array( 'wirecard', 'stripe_split' ) ) ) return $actions;
- $refund_statuses = explode( ",", $order->refund_statuses );
- //if( in_array( 'requested', $refund_statuses ) ) return $actions;
- $is_refundeds = explode( ",", $order->is_refundeds );
- if( !in_array( 0, $is_refundeds ) ) return $actions;
- // Refund Threshold check
- $refund_threshold = isset( $WCFMmp->wcfmmp_refund_options['refund_threshold'] ) ? $WCFMmp->wcfmmp_refund_options['refund_threshold'] : '';
- if( $refund_threshold ) {
- $current_time = strtotime( 'midnight', current_time( 'timestamp' ) );
- $date = date( 'Y-m-d', $current_time );
- $created_date = date( 'Y-m-d', strtotime($order->created) );
- $datetime1 = new DateTime( $date );
- $datetime2 = new DateTime( $created_date );
- $interval = $datetime2->diff( $datetime1 );
- $interval = $interval->format( '%r%a' );
- if( ( (int) $interval >= 0 ) && ( (int) $interval > (int) $refund_threshold ) ) return $actions;
- }
- $wc_order = wc_get_order( $order->order_id );
- if( $wc_order && is_a( $wc_order , 'WC_Order' ) ) {
- $created_via = $wc_order->get_created_via();
- if( $created_via && in_array( $created_via, apply_filters( 'wcfmmp_new_order_check_created_via', array( 'rest-api' ) ) ) ) {
- return $actions;
- }
- }
- $actions .= '<a class="wcfmmp_order_refund_request wcfm-action-icon" href="#" data-item="' . $order->item_id . '" data-commission="' . $order->ID . '" data-order="' . $order->order_id . '"><span class="wcfmfa fa-retweet text_tip" data-tip="' . esc_attr__( 'Refund Request', 'wc-multivendor-marketplace' ) . '"></span></a>';
- return $actions;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement