Loads all shipping methods which are hooked in.
If a $package is passed some methods may add themselves conditionally and zones will be used.
public load_shipping_methods ( array $package = [] ) : array | ||
$package | array | |
return | array |
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); }
/** * 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(); }
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); }
<?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'];