We are currently on vacation until 13th May 2024, ticket responses maybe be longer than normal during this period, sorry for any inconvenience.

Profit Margin!!!

Closed

Import WP Pro Updated 1 month ago 14 Replies

Edward asked 1 month ago on March 31, 2024 at 10:54 am

James,

Can you add profit margin to the plugin.  The other way didn’t work and I can’t find a plugin that works with your plugin.

Eddie

J

James replied Support Agent

1 month ago on March 31, 2024 at 7:04 pm

Hi Edward,

What do you mean by " The other way didn’t work", what have you tried?

The best way to achieve this would be to use a custom function (https://www.importwp.com/docs/modifying-dates-using-custom-methods/) to add  profit margin to prices, i you need help creating a custom function let me know and i can try to help.

James

ED

Edward replied privately

1 month ago on April 1, 2024 at 10:45 am

J

James replied Support Agent

1 month ago on April 1, 2024 at 3:17 pm

Hi Eddie,

Based on your mention of the custom field: _alg_wc_cog_profit_margin this suggests that the profit margin is specific to a plugin or theme.

If you can let me know what you need me to do and i can try to help.

But looking back on the old code to add vat onto a ex vat price, the following function should do that with a add profit percentage (https://www.importwp.com/docs/using-code-snippets-in-wordpress/):

function iwpex_add_vat_with_profit($priceExVat = '', $profitPercent = 0){
    $vatRate = 20;
    $profitPercent = floatval($profitPercent);
    $vatComponent = ($priceExVat / 100) * $vatRate;
    $priceIncVat = $priceExVat + $vatComponent;
    return $priceIncVat  + ($priceIncVat * $profitPercent);
}

Usage:

[iwpex_add_vat_with_profit("{5}", "0.2")]

This would add vat @ 20% and a 20% profit margin

e.g. if {5} was 10

10 + vat @ 20% = 12

12 + 20% profit = 14.4

 

ED

Edward replied

1 month ago on April 2, 2024 at 1:42 pm

I followed https://www.importwp.com/docs/using-code-snippets-in-wordpress/ and created a file with the following contents:

<?php

/**
 * Plugin Name: Import WP - Custom code
 * Plugin URI: https://www.importwp.com
 * Description: 
 * Version: 1.0.0 
 * Network: True
 */
function iwpex_add_vat_with_profit($priceExVat = '', $profitPercent = 0){
    $vatRate = 20;
    $profitPercent = floatval($profitPercent);
    $vatComponent = ($priceExVat / 100) * $vatRate;
    $priceIncVat = $priceExVat + $vatComponent;
    return $priceIncVat  + ($priceIncVat * $profitPercent);
}

but I cannot see the custom plugin in WordPress.  Do I put [iwpex_add_vat_with_profit("{5}", "0.2")] into a custome field box?

Regards

Eddie

J

James replied Support Agent

1 month ago on April 2, 2024 at 1:47 pm

When you created the custom file with the plugin code, did you upload it to your plugins folder?

If not i have attached a zipped version that you can upload via the plugins page and activate.

Once activate to confirm that its working if you add this to a custom field  it should show the calcualted value in the preview text:

[iwpex_add_vat_with_profit("{5}", "0.2")]
ED

Edward replied

1 month ago on April 2, 2024 at 2:10 pm

Hi James,

 

No, I created the file in the folder via File explorer in my cPanel. Is that where it went wrong?


J

James replied Support Agent

1 month ago on April 2, 2024 at 2:26 pm

It depends on where your wordpress stores its plugin files, this can change depending on the setup, its default location is wp-content/plugins. and then a file in that folder should appear in the plugins list, if it does not then they must be stores somewhere else.

Did you try uploading the previously attached zip file via the plugins admin page?

ED

Edward replied

1 month ago on April 2, 2024 at 4:55 pm

No I didn't I followed the instructions but  I should of thought of that.. It has now appeared in MUST USE plugin menu. I did try using IWP in conjunction with Bulk Price Edit Bulk Cost Price  but the cost price is not pulled in, all products are pulled in but not product cost field. 
J

James replied Support Agent

1 month ago on April 2, 2024 at 6:07 pm

If it is appearing in the must use plugin menu then you must have put it in the mu-plugins folder and not the plugins folder.

What is the cost price field? is this added by a plugin or theme?

ED

Edward replied

1 month ago on April 3, 2024 at 7:14 am

Good news is, with the help of Bulk Price Edit & Bulk Cost Edit plugins, I have managed to get it working, only thing is it is not pulling in the images from the URL, it shows error 404 in the notes at end of import, even though if you copy the url and paste into browser it shows the image.

J

James replied Support Agent

1 month ago on April 3, 2024 at 7:30 am

Can you attach a screenshot showing the importer 404 error from its history, along with the image url that it couldnt download but you can view?

ED

Edward replied privately

1 month ago on April 3, 2024 at 8:38 am

J

James replied Support Agent

1 month ago on April 3, 2024 at 8:48 pm

The only thing i can think of, is if the server is blocked by the http://www.spire.co.uk/ url, or that the domain doesnt resolve on the server.

Do you have ssh or terminal access on your webserver that has the importer on it, if so are you able to ping www.spire.co.uk to see if it can access that site?

ED

Edward replied

1 month ago on April 4, 2024 at 8:44 pm

It downloads the csv file in ImportWP and it has done some images but not all. 

 

I give up for now, I will try to find another way of doing it.

 

Thank you