Aakash
Forum Replies Created
-
Hi @nigel-lew You could use the PHP Function feature to manipulate your data as needed: https://www.wpallimport.com/documentation/import/custom-code/inline-php/
If you can share your import file and specify the fields you’re attempting to add, I can assist further with specific code. Hope this helped!
@ibrahimpak Excellent, glad you got it working to your liking!
@ibrahimpak The “
starts-with
” XPath function may help you get a bit closer.
/Product[Price[1][not(starts-with(.,"1,") )]]
However, I believe switching to “.” for “cents” separator in the source file is the best method. Then use WooCommerce settings/a plugin to change it to “,” as needed on the frontend/admin dashboard.
- This reply was modified 3 years ago by Aakash.
Hi @ibrahimpak
I’d recommend editing the source XML file to use “.” instead of “,” as the separator, then your XPath will filter correctly.
According to this post by WPAllImport and this by a WooCommerce dev, WooCommerce seems to prefer to have prices in this format.
Then you could use a plugin (or maybe there’s even a built in WooCommerce setting) to display price with comma to your frontend visitors.
Hope this helped
@ibrahimpak This may work:
function round_price( $price = null, $multiplier = 1, $nearest = .01, $minus = 0 ) { if ( (!empty($price)) and ($price >= 50) ) { // Remove any extra characters from price. $price = preg_replace("/[^0-9,.]/", "", $price); // Perform calculations and return rounded price. return ( round ( ( $price * $multiplier ) / $nearest ) * $nearest ) - $minus; } else { return $price: } }
Forum: Plugins
In reply to: [Import any XML, CSV or Excel File to WordPress] Add a link to a videoBy default, I don’t believe WooCommerce supports videos in the gallery.
If you add a plugin for this functionality (and assuming it uses the same database row as gallery images) then passing the video URL to WooCommerce image field would work.
Alternatively, you could upload the videos to YouTube, have the URL in your import, and put an embed in the product description.
@ibrahimpak If your goal is to only round the price if it’s 50 or above, put this as the function
function round_price( $price = null, $multiplier = 1, $nearest = .01, $minus = 0 ) { if ( (!empty($price)) and ($price >= 50) ) { // Remove any extra characters from price. $price = preg_replace("/[^0-9,.]/", "", $price); // Perform calculations and return rounded price. return ( round ( ( $price * $multiplier ) / $nearest ) * $nearest ) - $minus; } }
- This reply was modified 3 years ago by Aakash.
@ibrahimpak Nice job! Still need help with anything?
Feel free to mark this topic as “Resolved” if notHi @ffdltd
You may be able to use an XPath filter to only process entries where the first row CSV value isn’t blank. Depending on the way the plugin handles this case, it may work.
The XPath to filter entries where row 1 (in this example case “Name”) is blank:
/node[name[1] != ""]
Alternatively, you could enable “Manual Scheduling” and write a code snippet to check the file size and run the import. Here’s a rough example function:
function run_import(){ // Get the size of the CSV file $url = "https://sleepy-corncrake.w5.wpsandbox.pro/wp-content/uploads/2022/02/New-Sheet1.csv"; $data = get_headers($url, true); $size = isset($data['Content-Length'])?(int) $data['Content-Length']:0; // If the size is over 100kb, run the import and processing if ($size > 100){ file_get_contents("https://sleepy-corncrake.w5.wpsandbox.pro/wp-load.php?import_key=9k7buCXy&import_id=3&action=trigger"); file_get_contents("https://sleepy-corncrake.w5.wpsandbox.pro/wp-load.php?import_key=9k7buCXy&import_id=3&action=processing"); } }
You could use a plugin like WP Control to run this function via Cronjob.
Another possibility would be to tell the program which writes the CSV to not create blank files.
Hope this helped point you in the right direction.
@bsmolyanov I haven’t tested this yet, but this may do the trick:
function after_xml_import($import_id, $import) { switch ($import_id) { case 1: wp_remote_get('import2URL'); //replace with your import URL break; case 2: wp_remote_get('import3URL'); //replace with your import URL break; } } add_action('pmxi_after_xml_import', 'after_xml_import', 10, 2);
I also found this similar/cleaner solution for chaining cron jobs on the WPAllImport GitHub https://github.com/trey8611/wpiedocs/issues/2
Hope this helped!
Forum: Plugins
In reply to: [Import any XML, CSV or Excel File to WordPress] Add a link to a videoHi @valerymd
I think this question has more to do with WooCommerce itself.
From what I see, there are various plugins to add the ability to put videos in your product preview gallery – https://barn2.com/woocommerce-product-video-gallery/
Hope this helped
@ibrahimpak Nice job with the category and price filtering.
You should be able to filter via SKU the same way using an XPath filter.
The XPath “equal”, “not equal”, and “or” operators should be helpful.
XPath Operators – https://www.w3schools.com/xml/xpath_operators.aspWPAllImport XPath Filtering Docs – https://www.wpallimport.com/documentation/advanced/filtering-with-xpath/
If you still need help, you can share your CSV here and someone may be able to point you in the right direction.
Forum: Plugins
In reply to: [Import any XML, CSV or Excel File to WordPress] How to show attachment URL?Hi @s1fox
To display the “CertPDFURL” in the WooCommerce description, you can use the shortcode
{certpdfurl[1]}
If you’d like to hyperlink text to the URL, you can use a code like this:
<a href="https://{certpdfurl[1]}">View PDF</a>
Example: https://i.imgur.com/B3K1QGN.png
- This reply was modified 3 years ago by Aakash.
Forum: Plugins
In reply to: [Import any XML, CSV or Excel File to WordPress] How to show attachment URL?Can you show the file you’re trying to import and specify where the attachment URLs are?
Since you have the pro version of the plugin, you can get expedited support on the website – https://www.wpallimport.com/support/
Forum: Plugins
In reply to: [Import any XML, CSV or Excel File to WordPress] Overwrite all entriesHi @jjcarlson
Assuming Formidable Forms saves entries a custom post type, yes this is possible.
Here’s how to update properties of existing records on import – https://www.wpallimport.com/documentation/bulk-edit/update-existing-posts/
And here’s how to run an import on a schedule via cron job – https://www.wpallimport.com/documentation/recurring/cron/
Since you have the pro version of the plugin, you can get expedited support here – https://www.wpallimport.com/support/