summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorg089h515r8062012-08-11 11:57:45 (GMT)
committerg089h515r8062012-08-11 11:57:45 (GMT)
commit4022fa629e09d2cf68d26a703a9449fadf981ca8 (patch)
tree2ca2773785fe7120c4149912ee431dc57994d86c
parent0619365a1ca155229e0f57926c2c210a80a4233e (diff)
add example for shipping method7.x-1.0-alpha1
-rw-r--r--uc_ctools_example/plugins/ubercart/shipping_method/test_shipping_method.inc49
1 files changed, 49 insertions, 0 deletions
diff --git a/uc_ctools_example/plugins/ubercart/shipping_method/test_shipping_method.inc b/uc_ctools_example/plugins/ubercart/shipping_method/test_shipping_method.inc
new file mode 100644
index 0000000..d4c13f5
--- /dev/null
+++ b/uc_ctools_example/plugins/ubercart/shipping_method/test_shipping_method.inc
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * @file
+ * A payment method plugin for Ubercart.
+ */
+/**
+ * Define this Export UI plugin.
+ */
+$plugin = array(
+ 'id' => 'test_shipping_method',
+ 'module' => 'uc_ctools_example',
+ 'title' => 'test payment method',
+ 'description' => t('test payment method description'),
+ 'enabled' => TRUE,
+ 'operations' => array(
+ ),
+ 'quote' => array(
+ 'type' => 'order',
+ 'callback' => 'uc_ctools_example_quote_test_payment_method',
+ 'accessorials' => array(
+ 'test payment method',
+ ),
+ ),
+);
+
+/**
+ * Standard callback to return a shipping rate via the weight quote method.
+ *
+ * @param $products
+ * The order's products.
+ * @param $details
+ * Other order details including a shipping address.
+ * @return
+ * A JSON object containing the shipping quote for the order.
+ */
+function uc_ctools_example_quote_test_payment_method($products, $details, $method) {
+ $sum_weight = 0;
+ foreach ($products as $product) {
+ $sum_weight += $product->weight * $product->qty;
+ }
+ $shipping_fee = $sum_weight;
+ $quotes[] = array(
+ 'rate' => $shipping_fee,
+ 'label' => check_plain('test payment method'),
+ 'option_label' => check_plain('test payment method')
+ );
+ return $quotes;
+} \ No newline at end of file