add woo-commerce order to another platform via web service












0















I have a woo-commerce shop and a cod posting platform for delivering my products to the customer.
I need to add customers order to the COD via web service



in the function.php file of my theme, I did this for now but this script just add one of customers product into the order
I need to send all products in web service



$hook_to = 'woocommerce_thankyou';
$what_to_hook = 'add2postweb';
$prioriy = 111;
$num_of_arg = 1;
add_action($hook_to, $what_to_hook, $prioriy, $num_of_arg);



function add2postweb($order_id){

// Get an instance of the WC_Order object
$order = wc_get_order( $order_id );

$order_data = $order->get_data(); // The Order data
$order_payment_method = $order_data['payment_method'];
$order_billing_first_name = $order_data['billing']['first_name'];
$order_billing_last_name = $order_data['billing']['last_name'];
$order_billing_company = $order_data['billing']['company'];
$order_billing_address_1 = $order_data['billing']['address_1'];
$order_billing_address_2 = $order_data['billing']['address_2'];
$order_billing_city = $order_data['billing']['city'];
$order_billing_state = $order_data['billing']['state'];
$order_billing_postcode = $order_data['billing']['postcode'];
$order_billing_country = $order_data['billing']['country'];
$order_billing_email = $order_data['billing']['email'];
$order_billing_phone = $order_data['billing']['phone'];
$stuff_id=array();
$stuff_count=array();
// Iterating through each WC_Order_Item_Product objects
foreach ($order->get_items() as $item_key => $item_values):
## Access Order Items data properties (in an array of values) ##
$item_data = $item_values->get_data();
$product_name = $item_data['name'];
$product_id = $item_data['product_id'];
$variation_id = $item_data['variation_id'];
$quantity = $item_data['quantity'];
$tax_class = $item_data['tax_class'];
$line_subtotal = $item_data['subtotal'];
$line_subtotal_tax = $item_data['subtotal_tax'];
$line_total = $item_data['total'];
$line_total_tax = $item_data['total_tax'];
$username = '*******';
$password = '*******';

$client = new SoapClient('http://svc.ebazaar-post.ir/EshopService.svc?wsdl');
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;

$result = $client -> AddStuff ([
'username' => $username,
'password' => $password,
'name' => $product_name,
'price' => 501111000,
'weight' => 2010,
'count' => 1100,
'description' => 'تست',
'percentDiscount' => 0,
]);



$stuff_id=(int)$result->AddStuffResult;
$count=(int)$quantity;


endforeach;


echo'<<<<<<<<<<';
echo $stuff_id;
echo $count;
echo '>>>>>>>>>>';
$username = 'borujerd';
$password = 'Borujerd20#$';
$client = new SoapClient('http://svc.ebazaar-post.ir/EshopService.svc?wsdl');
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;
$result2 = $client -> AddParcel ([
'username' => $username,
'password' => $password,
'productsId' => [
[
'Id' => $stuff_id, // Product id in ebazaar
'Count' => $count, // Request Number Of Product
'DisCount' => 0 // No Discount
]
],
'cityCode' => 1,
'serviceType' => 1, // pishtaz
'payType' => 1,
'registerFirstName' => $order_billing_first_name,
'registerLastName' => $order_billing_last_name,
'registerAddress' => 'نشانی دریافت کننده',
'registerPhoneNumber' => '0912111111',
'registerMobile' => '0912111111',
'registerPostalCode' => '1648853978'
]);
}









share|improve this question





























    0















    I have a woo-commerce shop and a cod posting platform for delivering my products to the customer.
    I need to add customers order to the COD via web service



    in the function.php file of my theme, I did this for now but this script just add one of customers product into the order
    I need to send all products in web service



    $hook_to = 'woocommerce_thankyou';
    $what_to_hook = 'add2postweb';
    $prioriy = 111;
    $num_of_arg = 1;
    add_action($hook_to, $what_to_hook, $prioriy, $num_of_arg);



    function add2postweb($order_id){

    // Get an instance of the WC_Order object
    $order = wc_get_order( $order_id );

    $order_data = $order->get_data(); // The Order data
    $order_payment_method = $order_data['payment_method'];
    $order_billing_first_name = $order_data['billing']['first_name'];
    $order_billing_last_name = $order_data['billing']['last_name'];
    $order_billing_company = $order_data['billing']['company'];
    $order_billing_address_1 = $order_data['billing']['address_1'];
    $order_billing_address_2 = $order_data['billing']['address_2'];
    $order_billing_city = $order_data['billing']['city'];
    $order_billing_state = $order_data['billing']['state'];
    $order_billing_postcode = $order_data['billing']['postcode'];
    $order_billing_country = $order_data['billing']['country'];
    $order_billing_email = $order_data['billing']['email'];
    $order_billing_phone = $order_data['billing']['phone'];
    $stuff_id=array();
    $stuff_count=array();
    // Iterating through each WC_Order_Item_Product objects
    foreach ($order->get_items() as $item_key => $item_values):
    ## Access Order Items data properties (in an array of values) ##
    $item_data = $item_values->get_data();
    $product_name = $item_data['name'];
    $product_id = $item_data['product_id'];
    $variation_id = $item_data['variation_id'];
    $quantity = $item_data['quantity'];
    $tax_class = $item_data['tax_class'];
    $line_subtotal = $item_data['subtotal'];
    $line_subtotal_tax = $item_data['subtotal_tax'];
    $line_total = $item_data['total'];
    $line_total_tax = $item_data['total_tax'];
    $username = '*******';
    $password = '*******';

    $client = new SoapClient('http://svc.ebazaar-post.ir/EshopService.svc?wsdl');
    $client->soap_defencoding = 'UTF-8';
    $client->decode_utf8 = false;

    $result = $client -> AddStuff ([
    'username' => $username,
    'password' => $password,
    'name' => $product_name,
    'price' => 501111000,
    'weight' => 2010,
    'count' => 1100,
    'description' => 'تست',
    'percentDiscount' => 0,
    ]);



    $stuff_id=(int)$result->AddStuffResult;
    $count=(int)$quantity;


    endforeach;


    echo'<<<<<<<<<<';
    echo $stuff_id;
    echo $count;
    echo '>>>>>>>>>>';
    $username = 'borujerd';
    $password = 'Borujerd20#$';
    $client = new SoapClient('http://svc.ebazaar-post.ir/EshopService.svc?wsdl');
    $client->soap_defencoding = 'UTF-8';
    $client->decode_utf8 = false;
    $result2 = $client -> AddParcel ([
    'username' => $username,
    'password' => $password,
    'productsId' => [
    [
    'Id' => $stuff_id, // Product id in ebazaar
    'Count' => $count, // Request Number Of Product
    'DisCount' => 0 // No Discount
    ]
    ],
    'cityCode' => 1,
    'serviceType' => 1, // pishtaz
    'payType' => 1,
    'registerFirstName' => $order_billing_first_name,
    'registerLastName' => $order_billing_last_name,
    'registerAddress' => 'نشانی دریافت کننده',
    'registerPhoneNumber' => '0912111111',
    'registerMobile' => '0912111111',
    'registerPostalCode' => '1648853978'
    ]);
    }









    share|improve this question



























      0












      0








      0








      I have a woo-commerce shop and a cod posting platform for delivering my products to the customer.
      I need to add customers order to the COD via web service



      in the function.php file of my theme, I did this for now but this script just add one of customers product into the order
      I need to send all products in web service



      $hook_to = 'woocommerce_thankyou';
      $what_to_hook = 'add2postweb';
      $prioriy = 111;
      $num_of_arg = 1;
      add_action($hook_to, $what_to_hook, $prioriy, $num_of_arg);



      function add2postweb($order_id){

      // Get an instance of the WC_Order object
      $order = wc_get_order( $order_id );

      $order_data = $order->get_data(); // The Order data
      $order_payment_method = $order_data['payment_method'];
      $order_billing_first_name = $order_data['billing']['first_name'];
      $order_billing_last_name = $order_data['billing']['last_name'];
      $order_billing_company = $order_data['billing']['company'];
      $order_billing_address_1 = $order_data['billing']['address_1'];
      $order_billing_address_2 = $order_data['billing']['address_2'];
      $order_billing_city = $order_data['billing']['city'];
      $order_billing_state = $order_data['billing']['state'];
      $order_billing_postcode = $order_data['billing']['postcode'];
      $order_billing_country = $order_data['billing']['country'];
      $order_billing_email = $order_data['billing']['email'];
      $order_billing_phone = $order_data['billing']['phone'];
      $stuff_id=array();
      $stuff_count=array();
      // Iterating through each WC_Order_Item_Product objects
      foreach ($order->get_items() as $item_key => $item_values):
      ## Access Order Items data properties (in an array of values) ##
      $item_data = $item_values->get_data();
      $product_name = $item_data['name'];
      $product_id = $item_data['product_id'];
      $variation_id = $item_data['variation_id'];
      $quantity = $item_data['quantity'];
      $tax_class = $item_data['tax_class'];
      $line_subtotal = $item_data['subtotal'];
      $line_subtotal_tax = $item_data['subtotal_tax'];
      $line_total = $item_data['total'];
      $line_total_tax = $item_data['total_tax'];
      $username = '*******';
      $password = '*******';

      $client = new SoapClient('http://svc.ebazaar-post.ir/EshopService.svc?wsdl');
      $client->soap_defencoding = 'UTF-8';
      $client->decode_utf8 = false;

      $result = $client -> AddStuff ([
      'username' => $username,
      'password' => $password,
      'name' => $product_name,
      'price' => 501111000,
      'weight' => 2010,
      'count' => 1100,
      'description' => 'تست',
      'percentDiscount' => 0,
      ]);



      $stuff_id=(int)$result->AddStuffResult;
      $count=(int)$quantity;


      endforeach;


      echo'<<<<<<<<<<';
      echo $stuff_id;
      echo $count;
      echo '>>>>>>>>>>';
      $username = 'borujerd';
      $password = 'Borujerd20#$';
      $client = new SoapClient('http://svc.ebazaar-post.ir/EshopService.svc?wsdl');
      $client->soap_defencoding = 'UTF-8';
      $client->decode_utf8 = false;
      $result2 = $client -> AddParcel ([
      'username' => $username,
      'password' => $password,
      'productsId' => [
      [
      'Id' => $stuff_id, // Product id in ebazaar
      'Count' => $count, // Request Number Of Product
      'DisCount' => 0 // No Discount
      ]
      ],
      'cityCode' => 1,
      'serviceType' => 1, // pishtaz
      'payType' => 1,
      'registerFirstName' => $order_billing_first_name,
      'registerLastName' => $order_billing_last_name,
      'registerAddress' => 'نشانی دریافت کننده',
      'registerPhoneNumber' => '0912111111',
      'registerMobile' => '0912111111',
      'registerPostalCode' => '1648853978'
      ]);
      }









      share|improve this question
















      I have a woo-commerce shop and a cod posting platform for delivering my products to the customer.
      I need to add customers order to the COD via web service



      in the function.php file of my theme, I did this for now but this script just add one of customers product into the order
      I need to send all products in web service



      $hook_to = 'woocommerce_thankyou';
      $what_to_hook = 'add2postweb';
      $prioriy = 111;
      $num_of_arg = 1;
      add_action($hook_to, $what_to_hook, $prioriy, $num_of_arg);



      function add2postweb($order_id){

      // Get an instance of the WC_Order object
      $order = wc_get_order( $order_id );

      $order_data = $order->get_data(); // The Order data
      $order_payment_method = $order_data['payment_method'];
      $order_billing_first_name = $order_data['billing']['first_name'];
      $order_billing_last_name = $order_data['billing']['last_name'];
      $order_billing_company = $order_data['billing']['company'];
      $order_billing_address_1 = $order_data['billing']['address_1'];
      $order_billing_address_2 = $order_data['billing']['address_2'];
      $order_billing_city = $order_data['billing']['city'];
      $order_billing_state = $order_data['billing']['state'];
      $order_billing_postcode = $order_data['billing']['postcode'];
      $order_billing_country = $order_data['billing']['country'];
      $order_billing_email = $order_data['billing']['email'];
      $order_billing_phone = $order_data['billing']['phone'];
      $stuff_id=array();
      $stuff_count=array();
      // Iterating through each WC_Order_Item_Product objects
      foreach ($order->get_items() as $item_key => $item_values):
      ## Access Order Items data properties (in an array of values) ##
      $item_data = $item_values->get_data();
      $product_name = $item_data['name'];
      $product_id = $item_data['product_id'];
      $variation_id = $item_data['variation_id'];
      $quantity = $item_data['quantity'];
      $tax_class = $item_data['tax_class'];
      $line_subtotal = $item_data['subtotal'];
      $line_subtotal_tax = $item_data['subtotal_tax'];
      $line_total = $item_data['total'];
      $line_total_tax = $item_data['total_tax'];
      $username = '*******';
      $password = '*******';

      $client = new SoapClient('http://svc.ebazaar-post.ir/EshopService.svc?wsdl');
      $client->soap_defencoding = 'UTF-8';
      $client->decode_utf8 = false;

      $result = $client -> AddStuff ([
      'username' => $username,
      'password' => $password,
      'name' => $product_name,
      'price' => 501111000,
      'weight' => 2010,
      'count' => 1100,
      'description' => 'تست',
      'percentDiscount' => 0,
      ]);



      $stuff_id=(int)$result->AddStuffResult;
      $count=(int)$quantity;


      endforeach;


      echo'<<<<<<<<<<';
      echo $stuff_id;
      echo $count;
      echo '>>>>>>>>>>';
      $username = 'borujerd';
      $password = 'Borujerd20#$';
      $client = new SoapClient('http://svc.ebazaar-post.ir/EshopService.svc?wsdl');
      $client->soap_defencoding = 'UTF-8';
      $client->decode_utf8 = false;
      $result2 = $client -> AddParcel ([
      'username' => $username,
      'password' => $password,
      'productsId' => [
      [
      'Id' => $stuff_id, // Product id in ebazaar
      'Count' => $count, // Request Number Of Product
      'DisCount' => 0 // No Discount
      ]
      ],
      'cityCode' => 1,
      'serviceType' => 1, // pishtaz
      'payType' => 1,
      'registerFirstName' => $order_billing_first_name,
      'registerLastName' => $order_billing_last_name,
      'registerAddress' => 'نشانی دریافت کننده',
      'registerPhoneNumber' => '0912111111',
      'registerMobile' => '0912111111',
      'registerPostalCode' => '1648853978'
      ]);
      }






      php woocommerce






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '18 at 6:55









      Zain Farooq

      1,99821030




      1,99821030










      asked Nov 26 '18 at 6:30









      m.hatamim.hatami

      4411




      4411
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475776%2fadd-woo-commerce-order-to-another-platform-via-web-service%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475776%2fadd-woo-commerce-order-to-another-platform-via-web-service%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Create new schema in PostgreSQL using DBeaver

          Deepest pit of an array with Javascript: test on Codility

          Costa Masnaga