How to add a percentage or value to xml imported Price field

Closed

Import WP Pro Updated 1 year ago 3 Replies

Muhammad asked 1 year ago on August 29, 2023 at 3:05 pm

Hi, is there any way to accomplish the ffg as possible with some other import plugins:

 

1. Add an amount or a percentage to an imported price of the Woocommerce imported field to set the selling price higher than the supplier’s price? ( This amount or percentage will be different for different importers depending on the markup)

2. Import the cost price of an item into a field (how would you recommend adding a Cost Price field)

3. When importing from a supplier, Set the value of a field for WCFM multivendor to a particular vendor for the import.

 

 

 

 

J

James replied Support Agent

1 year ago on August 30, 2023 at 7:40 am

Hi Muhammad,

What do you mean by "ffg"?

1. you can modify data before it is imported , by creating a function in php that will add a amount or percentage onto your import value (an example of using custom methods, but the example shows how to do dates: https://www.importwp.com/docs/modifying-dates-using-custom-methods/) , if you need help with this let me know and attach an example csv/xml showing what should get an amount/ what amount/and what percentage.

2. How is the cost price field created in wordpress, this should hopefully be a case of adding a custom field with the correct name and value.

3. Can you provide more information in regards to this, how you set up your multi vendors, how they are connected, along with an example, and any plugins required to follow your example.

James

MS

Muhammad replied

1 year ago on September 3, 2023 at 11:32 pm

Firstly, I would like to commend you on your great work and amazing plugins.

Furthermore, 

My Apologies, I said 'ffg' as short dor 'the following'. 

 

1. 1. What's the best way to do this using functions or snippets plugins. - i need to have different markup pricrs on different importers and i will have multiple importers and add many more to my multi-vendor site.

1.2 can you please look into adding to your development roadmap an easy way to do this through having calculation fields in your plugin in future development.

 

2.  I will add a custom field via ACF or registering a new field in wordpress.

 

3. WCFM multi-vendor ultimate is the plugin I'm testing with this.. I have now resolved this and figured out that a Vendor is a normal WP user account under the hood so I have set the vendor via the Author field in your plugin... 

J

James replied Support Agent

1 year ago on September 5, 2023 at 8:45 pm

Using a custom method, you can add the following code to your website, this will allow you to set fixed, or percentage values onto a price.

function iwphd_update_price($input = '', $amount = 0, $type = 'fixed')
{
    switch ($type) {
        case 'fixed':
            $input = floatval($input) + $amount;
            break;
        case 'percent':
            $input = floatval($input) + (floatval($input) * ($amount / 100));
            break;
    }

    return $input;
}

Examples of using this:

1. Add a percentage based markup to the price (example adds 10% onto the original 100):

[iwphd_update_price('100', '10', 'percent')]

2. Add a fixed price markup (example adds 5 onto the original 10

[iwphd_update_price('10', '5')]

 

To use this will csv columns or xml nodes, enter the xml or csv selection in the correct parameter, e.g. for the first column in your csv sheet would be:

[iwphd_update_price('{0}', '5')]

 

In regards to your cost field, download and install the importwp acf addon to make it a simple as selecting the acf field as the custom field name, and setting the value: https://www.importwp.com/integrations/advanced-custom-fields/