@Dosakan

Почему не работает кнопка возврата товара на плагине WCFM (WP)?

Всем добрый день! У меня проблемы с работой плагина WCFM на вордпресс. Это плагин маркетплейса и в нем есть модуль возврата товара покупателем, но при нажатии на возврат товара в ЛК, ничего не происходит, а должно открываться окно popup. Помогите пожалуйста, сам не силен.

Код самой кнопки
<a href="/account/?user=1&tab=wc-orders#1375" class=" wcfm-refund-action">Возврат</a>


Вот то, что мне удалось найти связанного по ней в файлах
public function wcfmmp_refund_orders_actions( $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;
		}
		
		$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;
  }
  
  /**
   * WCFM Refund action at My Account Order actions
   */
  function wcfmmp_myaccount_refund_order_action( $actions, $order ) {
  	global $WCFM, $WCFMmp, $wpdb;
  	
  	if( !apply_filters( 'wcfm_is_allow_customer_refund', true ) ) return $actions;
  	
  	$refund_by_customer = isset( $WCFMmp->wcfmmp_refund_options['refund_by_customer'] ) ? $WCFMmp->wcfmmp_refund_options['refund_by_customer'] : 'no';
  	if( $refund_by_customer == 'no' ) return $actions;
  		
  	$order_id = $order->get_id();
  	
  	$wcfm_refund_request = get_post_meta( $order_id, '_wcfm_refund_request', true );
  	if( $wcfm_refund_request ) return $actions;
  	
  	$order_status = sanitize_title( $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;
  	
  	$withdraw_status  = 'pending';
  	$refund_status    = '';
		$vendor_id        = 0;
		$is_refunded      = 0;
		
		$sql = 'SELECT ID, withdraw_status, vendor_id, refund_status, is_refunded FROM ' . $wpdb->prefix . 'wcfm_marketplace_orders AS commission';
		$sql .= ' WHERE 1=1';
		$sql .= " AND `order_id` = " . $order_id;
		$commissions = $wpdb->get_results( $sql );
		if( !empty( $commissions ) ) {
			foreach( $commissions as $commission ) {
				$withdraw_status  = $commission->withdraw_status;
				$vendor_id        = $commission->vendor_id;
				$refund_status    = $commission->refund_status;
				$is_refunded      = $commission->is_refunded;
				
				if( !$is_refunded && ( $refund_status != 'requested' ) ) break;
			}
		}
		
		//if( $withdraw_status != 'pending' ) return $actions;
		if( $refund_status == 'requested' ) return $actions;
		if( $is_refunded ) 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 );
			$order_date = ( version_compare( WC_VERSION, '2.7', '<' ) ) ? $order->order_date : $order->get_date_created();
			$created_date = date( 'Y-m-d', strtotime($order_date) );
			$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;
		}
  	
  	$actions['wcfm-refund-action'] = array( 'name' => __( 'Refund', 'wc-multivendor-marketplace' ), 'url' => '#' . $order_id );
  	return $actions;
  }


JS

// Vendor Refund
	$( document.body ).on( 'updated_wcfm-orders', function() {
		$('.wcfmmp_order_refund_request').each(function() {
			$(this).click(function(event) {
				event.preventDefault();
				$order_id = $(this).data('order');
				initRefundPopup( $(this), $order_id, true, 'no' );
			});
		});
	});
	
	// Customer Refund
	$('.wcfm-refund-action').each(function() {
		$(this).click(function(event) {
			event.preventDefault();
			$order_id = $(this).attr('href');
			initRefundPopup( $(this), $order_id, false, 'yes' );
		});
	});
  • Вопрос задан
  • 49 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы