Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Importing data into CartThrob order items field

Status Resolved
Add-on / Version DataGrab 5.0.2
Severity
EE Version 7.2.16

John Faulds

May 07, 2023

I think I mentioned this elsewhere about importing CartThrob order data from one site to another. I’m in the process of setting up a DG import on my site and have a question about setting up the order_items fieldtype.

DG shows this for the configuration: https://www.dropbox.com/s/56puoucmzlq3eiv/cartthrob%20order%20items.png?dl=0

I’m unsure how to configure the modifier field. With CT, I can add custom information to an order with the {item_options:xxxxx} tag. For instance, for the site I’m working on, I have {item_options:product_code} and {item_options:product_colour}.

Using those tags in the add_to_cart_form or update_cart_form will create the custom options and the same tags can be used to retrieve the information too (like in my XML templates).

CT takes that data and base64 serializes it before adding it to the `extra` column in the cartthrob_order_items table.

Do I need to have a `modifier` element in my XML that contains all the `item_options` pieces of information? Something like:

<modifier><![CDATA[{item:product_colour}]]>,<![CDATA[{item:product_code}]]></modifier>

Or something else?

#1

BoldMinded (Brian)

To be completely honest I have no idea. The CT field type is the one I know least about since taking over DG, and CT itself is a very complicated add-on that I personally haven’t used in over 8 years. Just setting up a CT install to replicate issues is very time consuming. If you can package up the whole site with an .sql database dumb I can try to take a look at this locally but it could be a few days. You might also be able to get an answer from the CT team.

#2

John Faulds

Comment has been marked private.

#3

BoldMinded (Brian)

What does your import file look like right now, can you share it?

#4

BoldMinded (Brian)

I do want to take a moment and point out the “Scenarios which may require a support fee” section in my support terms. https://boldminded.com/support-terms-conditions

#5

John Faulds

Comment has been marked private.

#6

John Faulds

Sample, not same.

#7

BoldMinded (Brian)

Which node in the xml file is supposed to be the modifier value? Based on the code in DG the modifier column is treated the same as the size, price, quantity, etc fields.

#8

BoldMinded (Brian)

The site you sent doesn’t have DataGrab installed… I need to see how the import is configured and be able to run the import in order to assist.

#9

BoldMinded (Brian)

This site is also running EE 6.3, 6.4 is the min supported version of DataGrab.

#10

John Faulds

Comment has been marked private.

#11

BoldMinded (Brian)

I was able to use the site you sent and replicate the issue. I think the issue is that the Cartthrob support that is in DataGrab is very old… as in it has not been updated for newer versions of Cartthrob. This doesn’t surprise me b/c the previous owner of DG barely did anything to support it for years. What you see in that screenshot are hard-coded options that DG recognizes, but I think at some point in CT’s history the order items field was updated to allow users to add any number of columns/options to the field, and DG doesn’t recognize that.

I need to think about how I’m going to approach this, and figure out when I can find time to work on it considering my current work load.

#12

BoldMinded (Brian)

The next comment is going to contain a new build with some crude improved support for the CT field type. You’ll need to update your XML import file so that there is an “extra” node, and it contains a JSON object. For example:

<row>
        <entry_id><![CDATA[11749]]></entry_id>
        <entry_date><![CDATA[1681970979]]></entry_date>
        <title><![CDATA[Houndstooth]]></title>
        <quantity><![CDATA[4]]></quantity>
        <![CDATA[$36]]></price>
        <extra><![CDATA[
          {
              "discount": 1,
              "price_plus_tax": "$40",
              "product_color": "HOUNDST05 Evergreen",
              "product_code": "HOUNDST05"
          }
        ]]></extra>
      </row>

I tested this and it seemed to work. You may need to edit the import config b/c there is no more “modifier” option. It was replaced with “extra”. You might have to delete your imported items and re-import too.

#13

BoldMinded (Brian)

Comment has been marked private.

#14

John Faulds

Great, thanks Brian! Appreciate the quick turn-around. I’ll test it out and see how it goes.

#15

John Faulds

So with this:

<entries>
  <entry>
    <title>Order #14640</title>
    <slug>order_14640</slug>
    <date>04/20/2023</date>
    <status>open</status>
    <subtotal>144</subtotal>
    <tax>18</tax>
    <total>177</total>
    <order_item>
      <entry_id>11749</entry_id>
      <entry_date>1681970979</entry_date>
      <title>Houndstooth</title>
      <quantity>4</quantity>
      $36</price>
      $40</price_plus_tax>
      <extra>
      { "discount": 0, "product_color": "HOUNDST05 Evergreen", "product_code": "HOUNDST05" }
      </extra>
    </order_item>
  </entry>
</entries>

and this config: https://www.dropbox.com/transfer/AAAAAKjxubYTRgxc5wllOEIniE-OVHG15hxRPdCTVES0VrLtuyFyciM

I get all the data except the order items.

#16

John Faulds

For some reason the code tags in the comments are removing the opening price and price_plus_tax tags.

#17

BoldMinded (Brian)

I have no idea what I did yesterday that made this “work”, but I clearly missed something and didn’t test very well. Next comment should have a working build.

#18

BoldMinded (Brian)

Comment has been marked private.

#19

John Faulds

Thanks, Brian, that’s working now. 😊

Another issue has come up though which isn’t related to the CT order items so I’ll create a new ticket.

Login to reply