403Webshell
Server IP : 62.60.133.156  /  Your IP : 216.73.217.51
Web Server : LiteSpeed
System : Linux linux24.centraldnserver.com 4.18.0-553.141.2.lve.el8.x86_64 #1 SMP Wed Jul 8 16:10:02 UTC 2026 x86_64
User : mimradmin ( 1166)
PHP Version : 7.4.33
Disable Function : show_source, system, shell_exec, passthru, exec, popen, proc_open
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : OFF |  Pkexec : OFF
Directory :  /proc/self/cwd/wp-content/plugins/persian-woocommerce-shipping/methods/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /proc/self/cwd/wp-content/plugins/persian-woocommerce-shipping/methods/pws-courier-method.php
<?php
/**
 * Developer : MahdiY
 * Web Site  : MahdiY.IR
 * E-Mail    : M@hdiY.IR
 */

defined( 'ABSPATH' ) || exit;

if ( class_exists( 'WC_Courier_Method' ) ) {
	return;
} // Stop if the class already exists

class WC_Courier_Method extends PWS_Shipping_Method {

	/**
	 * Base calculation cost
	 *
	 * @var int
	 */
	public $base_cost = 0;

	/**
	 * Cost per KG
	 *
	 * @var int
	 */
	public $per_cost = 0;

	public function __construct( $instance_id = 0 ) {

		$this->id                 = 'WC_Courier_Method';
		$this->instance_id        = absint( $instance_id );
		$this->method_title       = __( 'پیک موتوری' );
		$this->method_description = __( 'ارسال با استفاده از پیک موتوری' );

		parent::__construct();
	}

	public function init() {

		parent::init();

		$this->base_cost = intval( $this->get_option( 'base_cost' ) );
		$this->per_cost  = intval( $this->get_option( 'per_cost' ) );

		add_action( 'woocommerce_update_options_shipping_' . $this->id, [ $this, 'process_admin_options' ] );
	}

	public function init_form_fields() {

		$currency_symbol = get_woocommerce_currency_symbol();

		$this->instance_form_fields += [
			'base_cost' => [
				'title'       => 'هزینه پایه',
				'type'        => 'price',
				'description' => 'مبلغ حمل و نقل به روش پیک موتوری را به ' . $currency_symbol . ' وارد نمائید.',
				'default'     => 0,
			],
			'per_cost'  => [
				'title'       => 'هزینه به ازای هر کیلوگرم',
				'type'        => 'price',
				'description' => 'در صورتی که قصد دارید به ازای هر کیلوگرم هزینه اضافی دریافت شود هزینه را به ' . $currency_symbol . ' وارد نمائید.',
				'default'     => 0,
				'desc_tip'    => true,
			],
		];

	}

	public function is_available( $package = [] ): bool {

		$options = PWS()->get_terms_option( $this->get_destination( $package ) );

		$this->is_available = count( array_column( $options, 'courier_on' ) ) == count( $options );

		return parent::is_available( $package );
	}

	public function calculate_shipping( $package = [] ) {

		if ( $this->free_shipping( $package ) ) {
			return;
		}

		$cost = $this->base_cost;

		$options = PWS()->get_terms_option( $this->get_destination( $package ) );
		$options = array_column( $options, 'courier_cost' );

		foreach ( $options as $option ) {
			if ( $option != '' ) {
				$cost = intval( $option );
				break;
			}
		}

		$cost += ceil( $this->cart_weight / 1000 ) * $this->per_cost;

		$this->add_rate_cost( $cost, $package );
	}
}

Youez - 2016 - github.com/yon3zu