Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9101409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:07:26+00:00 2026-06-17T01:07:26+00:00

I am using XMLRPC to build an XML structure that passes across product information

  • 0

I am using XMLRPC to build an XML structure that passes across product information to a 3rd party system. I need to build an associative array of the product custom options and I don’t know what syntax to use as the value in each case is an object.

I can’t debug and play about with it as I normally would as believe it or not I’ve had to do this on a live site so I’ve been emailing myself the array to make sure it looks alright, then when it does I’ve applied it to the site, XMLRPC throws an error saying it can’t serialize the object I’ve built, then I quickly switch it back out again.

If I hardcode it like this it works fine.

    $item_array = array(
       "product_id" => new xmlrpcval($item->getSku()),
       "name" => new xmlrpcval($item->getName()),
       "price" => new xmlrpcval($item->getBaseCalculationPrice(), 'double'),
       "vat_inclusive" => new xmlrpcval(0,'int'),
       "quantity" => new xmlrpcval($item->getQty(),'int'),
       "option_text" => new xmlrpcval(
           array(
              "option_1" => new xmlrpcval("Colour: Military Black"),
              "option_2" => new xmlrpcval("Sizes: L")
           ),
           "struct")                          
        );

It’s the folowing section I need to generate, specifically the array in a foreach loop as I don’t know how many options there will be;

       "option_text" => new xmlrpcval(
           array(
              "option_1" => new xmlrpcval("Colour: Military Black"),
              "option_2" => new xmlrpcval("Sizes: L")
           ),
           "struct")  

If I do it like below then it comes out fine, but the value is a string rather than an object, which XMLRPC can’t serialize;

      $optioncount = 1;
      $attList = array();

      foreach ( $attributes as $attribute => $value ) {

          $attpair = implode(": ", $value);

          $attList['option_'. $optioncount] = 'new xmlrpcval("'.$attpair.'")';

          $optioncount++;

      }

If I var_dump($attList) I get;

array(2) {
  ["option_1"]=>
  string(39) "new xmlrpcval("Colour: Military Black")"
  ["option_2"]=>
  string(25) "new xmlrpcval("Sizes: L")"
}

Any other way seems to turn $attList into a total mess – I know this should be very basic but for the life of my I can’t get this working. Thanks for any pointers.

If I var_dump($attList) when I use new xmlrpcval($attpair); I get;

array(2) {
  ["option_1"]=>
  object(xmlrpcval)#469 (3) {
    ["me"]=>
    array(1) {
      ["string"]=>
      string(22) "Colour: Military Black"
    }
    ["mytype"]=>
    int(1)
    ["_php_class"]=>
    NULL
  }
  ["option_2"]=>
  object(xmlrpcval)#433 (3) {
    ["me"]=>
    array(1) {
      ["string"]=>
      string(8) "Sizes: L"
    }
    ["mytype"]=>
    int(1)
    ["_php_class"]=>
    NULL
 }

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:07:27+00:00Added an answer on June 17, 2026 at 1:07 am

    Building your array must look like:

      $optioncount = 1;
      $attList = array();
    
      foreach ( $attributes as $attribute => $value ) {
    
          $attpair = implode(": ", $value);
    
          $attList['option_'. $optioncount] = new xmlrpcval($attpair);
    
          $optioncount++;
    
      }
    

    And then:

    "option_text" => new xmlrpcval(
           $attList,
           "struct")  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started using a 3rd party API that depends on XML-RPC.NET using CookComputing.XmlRpc; I
I've got a system where some C++ code (using xmlrpc-c) talks to a Java
I am using xmlrpc-c library (c++ version) to write a program. I find that
I would like to build an XML over HTTP provisioning interface using Zend Framework.
Using a class that has an xmlrpc proxy as one of it's object's properties
I am using the CookComputing XML-RPC Library in an attempt to build a C#
I'm working on a Rails project that requires using an XMLRPC protocol to access
I m using a bash script to curl an XMLRPC file. However, the XML
I'm working with android xml rpc to mount a server. For that I'm using
I need to write application in PHP that supports Wordpress XML-RPC and allows to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.