当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Shipping::load_shipping_methods方法代码示例

本文整理汇总了PHP中WC_Shipping::load_shipping_methods方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Shipping::load_shipping_methods方法的具体用法?PHP WC_Shipping::load_shipping_methods怎么用?PHP WC_Shipping::load_shipping_methods使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Shipping的用法示例。


在下文中一共展示了WC_Shipping::load_shipping_methods方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: gmdate

    function checkfermopoint_merchant_callback()
    {
        echo "<h1>Riepilogo ticket Fermo!Point</h1>";
        $shippings_wc = new WC_Shipping();
        $shippings = $shippings_wc->load_shipping_methods();
        $fermopoint = $shippings["Fermo!Point"];
        //echo json_encode($fermopoint->settings);
        $fermopoint_settings = $fermopoint->settings;
        $account_id = $fermopoint_settings["FERMOPOINT_ACCOUNT_ID"];
        $account_secret = $fermopoint_settings["FERMOPOINT_ACCOUNT_SECRET"];
        $sandbox = $fermopoint_settings["sandbox"];
        $url = $sandbox == "yes" ? "http://www.sandbox.fermopoint.it/api/v1.2/merchant" : "http://api.fermopoint.it/api/v1.2/merchant";
        $ts = gmdate('Y-m-d\\TH:i:s.u\\Z');
        $auth_token = hash_hmac("sha256", (string) $ts, (string) $account_id . $account_secret, false);
        $request_url = '{
			"client_id": "' . $account_id . '",
			"ts": "' . $ts . '",
			"auth_token": "' . $auth_token . '",
			"data":{}
		}';
        $request = json_encode(array("client_id" => $account_id, "auth_token" => $auth_token, "ts" => $ts, "data" => array()));
        $httpHeader = array("Content-Type: application/json; charset=\"utf-8\"", "Accept: text/json");
        $ch = curl_init();
        $connect_timeout = 5;
        //sec
        $base_time_limit = (int) ini_get('max_execution_time');
        if ($base_time_limit < 0) {
            $base_time_limit = 0;
        }
        $time_limit = $base_time_limit - $connect_timeout - 2;
        if ($time_limit <= 0) {
            $time_limit = 20;
            //default
        }
        curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connect_timeout);
        curl_setopt($ch, CURLOPT_TIMEOUT, $time_limit);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
        curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $result = curl_exec($ch);
        $info = curl_getinfo($ch);
        if (!isset($info['http_code'])) {
            $info['http_code'] = '';
        }
        $curl_errno = curl_errno($ch);
        $curl_error = curl_error($ch);
        if (curl_errno($ch)) {
            $result = array('http_code' => $info['http_code'], 'status' => 'ERROR1', 'errno' => $curl_errno, 'error' => $curl_error, 'result' => NULL);
        } else {
            $ret = json_decode($result);
        }
        //var_dump($result);
        //var_dump($ret);
        ?>
        
        <h2>Crediti restati: <?php 
        echo $ret->credits;
        ?>
</h2>
		<h2>Ordini totali: <?php 
        echo $ret->orders_count;
        ?>
</h2>
        
        
        <table>
        
        	<?php 
        $orders = $ret->orders;
        if (count($orders) > 0) {
            foreach ($orders as $order) {
                ?>
						<tr>
							<?php 
                foreach ($order as $col) {
                    ?>
<td><?php 
                    echo $col;
                    ?>
</td><?php 
                }
                ?>
						</tr>
					<?php 
            }
        }
        ?>
        
        </table>
        
		<?php 
        curl_close($ch);
    }
开发者ID:ssimo84,项目名称:fermopoint-woocommerce,代码行数:99,代码来源:class-fermopoint-admin.php

示例2: get_shipping_methods

 /**
  * WooCommerce handles shipping methods on a per class/instance basis. So in order to have a
  * shipping method, we must have a class file that registers itself with 'woocommerce_shipping_methods'.
  */
 public function get_shipping_methods($params)
 {
     $klass = new WC_Shipping();
     $klass->load_shipping_methods();
     $methods = array();
     foreach ($klass->shipping_methods as $sm) {
         $methods[] = array('id' => $sm->id, 'name' => $sm->title, 'display_name' => $sm->method_title, 'enabled' => $sm->enabled, 'settings' => $sm->settings, 'plugin_id' => $sm->plugin_id);
     }
     $this->result->setPayload($methods);
     return $this->done();
 }
开发者ID:borisdiakur,项目名称:woocommerce-json-api,代码行数:15,代码来源:version1.php

示例3: getfieldfermopoint

 public function getfieldfermopoint()
 {
     //header('Content-Type: application/json');
     //check_ajax_referer('creajsbarcode','security');
     $shippings_wc = new WC_Shipping();
     $shippings = $shippings_wc->load_shipping_methods();
     $fermopoint = $shippings["Fermo!Point"];
     //echo json_encode($fermopoint->settings);
     $fermopoint_settings = $fermopoint->settings;
     $account_id = $fermopoint_settings["FERMOPOINT_ACCOUNT_ID"];
     $account_secret = $fermopoint_settings["FERMOPOINT_ACCOUNT_SECRET"];
     $sandbox = $fermopoint_settings["sandbox"];
     $url = $sandbox == "yes" ? "http://www.sandbox.fermopoint.it/RedirectApi" : "http://www.fermopoint.it/RedirectApi";
     //echo json_encode($shippings_wc );
     return array("id" => html_entity_decode($account_id), "secret" => html_entity_decode($account_secret), "url" => $url, "sandbox" => $sandbox);
 }
开发者ID:ssimo84,项目名称:fermopoint-woocommerce,代码行数:16,代码来源:class-fermopoint-public.php

示例4: array

<?php

include_once ABSPATH . 'wp-content/plugins/Bst_Manufacture/shippingmodule/class_show_shipping_wise_form.php';
include_once ABSPATH . 'wp-content/plugins/Bst_Manufacture/shippingmodule/class_show_weight_wise_shipping.php';
include_once ABSPATH . 'wp-content/plugins/Bst_Manufacture/shippingmodule/class_weight_htmlform.php';
global $wpdb;
/* code to call shipping methods */
$obj = new WC_Shipping();
$shippingmethod = $obj->load_shipping_methods();
$obnew = new WC_Weight_Based_Shipping();
/*print_r(WC_Weight_Based_Shipping::PLUGIN_PREFIX);
die;*/
/* End */
/*
 * HTML Fields for flat rate
 */
$objshipfltrate = new WC_Shipping_Flat_Rateextended();
$fieldflatrate = $objshipfltrate->settingfield();
$flatrate = '<table class="form-table"><tbody>';
$flatratefield = array();
unset($fieldflatrate['availability']);
unset($fieldflatrate['countries']);
$vid = get_the_ID();
$table = $wpdb->prefix . 'yith_vendors_shipping';
$getresult = $wpdb->get_results('select * from ' . $table . ' where vid=' . $vid);
$GLOBALS['shippingrest'] = $getresult;
if ($getresult[0]->flatrate) {
    $flatrateval = $getresult[0]->flatrate;
    $unserializeVal = unserialize($flatrateval);
    $fieldflatrate['enabled']['default'] = $unserializeVal['enabled'];
    $fieldflatrate['cost']['default'] = $unserializeVal['cost'];
开发者ID:kanhaiyasharma,项目名称:Bestswiss,代码行数:31,代码来源:Bst_shippingclass.php


注:本文中的WC_Shipping::load_shipping_methods方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。