• Resolved FilipeOS

    (@filipeos)


    Hi,

    So, I tried to set a few functions but the sale price was being set before the custom fields I set. = different random sale discount.

    Then I tried the other approach, trying global variables BUT the code seems not be executed in each products

    (this 2 options were working in testing, not import)

    Now my approach changed, in some fields I repeated the code and it’s working fine BUT, I still need to get the % of discount that were generated in another function. My question is, can I use a function to get 2 custom fields values, make the math and save it? How?

    Since global variables don’t work in my case.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @filipeos,

    My question is, can I use a function to get 2 custom fields values, make the math and save it? How?

    You can do that after the product is saved via our pmxi_saved_post hook, see: https://www.wpallimport.com/documentation/action-reference/.

    Since global variables don’t work in my case.

    If you have some data that you need to save and reference later in different code, you might want to consider the options API: https://developer.wordpress.org/plugins/settings/options-api/.

    Thread Starter FilipeOS

    (@filipeos)

    so, if I use that function how I call it? Just add the function and put the code inside?

    but if the global variable is not working it will not get passed anyway?

    Plugin Author WP All Import

    (@wpallimport)

    Hi @filipeos,

    so, if I use that function how I call it? Just add the function and put the code inside?

    Yes, the pmxi_saved_post hook is called each time a record is imported, so that’s when the code runs. You can learn more about WordPress hooks at https://developer.wordpress.org/plugins/hooks/.

    I suggested this because the free version of WP All Import doesn’t support inline PHP functions.

    but if the global variable is not working it will not get passed anyway?

    I’m not sure what went wrong with the global variable in your previous tests, so I can’t really comment on this.

    Thread Starter FilipeOS

    (@filipeos)

    i have the premium version of wp all import. What would be the code to pick the sale price, the regular price and assign to a custom field?

    since the other methods did not work for me? I searched documentation but nothing I understand was found

    Plugin Author WP All Import

    (@wpallimport)

    Hi @filipeos,

    i have the premium version of wp all import. What would be the code to pick the sale price, the regular price and assign to a custom field?

    Please send this question to http://www.wpallimport.com/support/. We can only answer questions about the free version of our plugins in this forum.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Global variables’ is closed to new replies.