Woocommerce送货方式

时间:2015-11-26 21:27:59

标签: php wordpress woocommerce

我想为Woocommerce开发一个送货插件 我想将参数发送给第三方api

告诉我该怎么做才是正确的

姓名电话邮件是必需的。

这是我的代码

英语不好,请原谅我。

我该如何解决这个问题? 谢谢。

    <?php
/*
Plugin Name: Ship
Plugin URI: http://woothemes.com/woocommerce
Description: Ship-Jay Hsu
Version: 1.0.0
Author: JayHsu
Author URI: http://
*/

/**
 * Check if WooCommerce is active
 */
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
    function EG($order){
        global $woocommerce; global $post;
    $billing_first_name =  $woocommerce->session->get('billing_first_name');
$billing_last_name = $woocommerce->session->get('billing_last_name');

    $cardurl =  'http://myshoptest.net.php?'.
                        '&Pay_zg=41' .
                        '&Rvg2c=1' .
                        '&Od_sob=' .$order_name.
                        '&Pur_name=' .$billing_first_name.$billing_last_name.
                        '&Mobile_number=' .$order->billing_phone.
                        '&Email=' .$order->billing_email.
                        '&Roturl_status=' . 'woook'.
                        '&Roturl=' . $Vk.
                        '&Remark=woocommerce';      
            header("Location: $cardurl"); 
            exit();
            }               
        function SFNM_init() {
                if ( ! class_exists( 'WC_SFNM' ) ) {
                        class WC_SFNM extends WC_Shipping_Method {
                                /**
                                 * Constructor for your shipping class
                                 *
                                 * @access public
                                 * @return void
                                 */
                                public function __construct() {
                                        $this->id                 = 'SFNM'; // Id for your shipping method. Should be uunique.
                                        $this->method_title       = __( 'Ship' );  // Title shown in admin
                                        $this->method_description = __( 'Ship' ); // Description shown in admin

                                        $this->enabled            = "yes"; // This can be added as an setting but for this example its forced enabled
                                        $this->title              = "Ship"; // This can be added as an setting but for this example its forced.

                                        $this->init_form_fields();
                                        $this->init();
                                }

                                /**
                                 * Init your settings
                                 *
                                 * @access public
                                 * @return void
                                 */
                                function init() {
                                        // Load the settings API
                                        $this->init_form_fields(); // This is part of the settings API. Override the method to add your own settings
                                        $this->init_settings(); // This is part of the settings API. Loads settings you previously init.

                                        // Save settings in admin if you have any defined
                                        add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) );
                                }




                                /**
                                 * calculate_shipping function.
                                 *
                                 * @access public
                                 * @param mixed $package
                                 * @return void
                                 */
                                public function calculate_shipping( $package ) {
                                        $rate = array(
                                                'id' => $this->id,
                                                'label' => $this->title,
                                                'cost' => '60',
                                                'calc_tax' => 'per_item'
                                        );

                                        // Register the rate
                                        $this->add_rate( $rate );
                                }


                        }
                }
        }





        add_action( 'woocommerce_shipping_init', 'SFNM_init' );

      add_action( 'woocommerce_thankyou','EG');
        function add_SFNM_method( $methods ) {
                $methods[] = 'WC_SFNM';
                return $methods;
        }

        add_filter( 'woocommerce_shipping_methods', 'add_SFNM_method' );
}



?>

0 个答案:

没有答案