Importing WooCommerce products into WordPress with custom fields and multiple product categories

If you are trying to import products into WooCommerce that have custom fields, you can try the Really Simple CSV Importer plugin and follow my instructions below.

Note that the Really Simple CSV Importer plugin v1.3 has not been updated for years, however it still works fine as of WordPress v5.8 for importing WooCommerce products.
In order to use it, you go to TOOLS then IMPORT and you will see it in the list import tools to choose from.

Some caveats with Really Simple CSV Importer plugin:
– The CSV file needs to be UTF-8.
– The header row of CSV file should NOT have double-quotes around each field.
– Each row in the CSV file (except the header row) should have double-quotes around each field.
– Each field in each row must use a comma as the seperator.
– To import to a custom field (meta field) called my_custom_field just use that exact name in the header row field name.
– To import to a hidden custom field called (hidden meta field) _my_custom_hidden_field you need to put an _underscore_ in front of the header row field name.
– It appears that post_id and post_name are required in the header row fields, but you can leave them blank and they will be automatically be generated.
– post_category generates a category under POSTS instead of PRODUCTS, so leave post_category blank.
– To import to a woocommerce specific custom field, you can use the following in the header row fields (these are just some of them):
  For REGULAR PRICE use: _regular_price
  For SALE PRICE use: _sale_price
  For the displayed PRICE use: _price
  For SKU use: _sku
  For STOCK MANAGEMENT (yes or no) use: _manage_stock
  For STOCK QUANTITY use: _stock
  For PRODUCT CATEGORY use (can only specify a single category): tax_product_cat
  For PRODUCT TYPE use (simple): tax_product_type
  For SHOP CATALOG or SEARCH visibility use (can specify one of exclude-from-search or exclude-from-catalog): tax_product_visibility

Here is a sample CSV file you can copy and paste:

post_id,post_name,post_title,post_content,post_author,post_date,post_tags,post_category,post_thumbnail,post_type,post_status,_sku,_regular_price,_price,_stock,_manage_stock,_visibility,tax_product_visibility,tax_product_type,tax_product_cat,_custom_field_hidden,custom_field_meta
"","my-first-product-url-slug","My first product name","description","","","","","https://mywordpresssite.com/wp-content/uploads/first-product-featured-image.jpg","product","publish","first-product-sku","50","50","3","yes","hidden","exclude-from-search","simple","my-product-category","hidden meta field","meta field"
"","my-second-product-url","My second product name","description","","","","","https://mywordpresssite.com/wp-content/uploads/second-product-featured-image.jpg","product","publish","second-product-sku","20","20","4","yes","hidden","exclude-from-catalog","simple","another-product-category","hidden meta field","meta field"

MODIFICATIONS TO CODE
I have created a couple modifications to the Really Simple CSV Importer code that will allow the following:
– Add multiple product categories seperated by the pipe | character: “my-product-cat|another-product-cat”
– Add both product visibility options seperated by the pipe | character: “exclude-from-catalog|exclude-from-search”
– Add a new header row option called “tax_search_exclude” which will allow you use the SEARCH EXCLUDE plugin: “yes”
NOTE: The exclude-from-search option will only hide products from the WooCommerce search but not from the WordPress search. In order to also hide products from the WordPress search, you need to use the SEARCH EXCLUDE plugin https://wordpress.org/plugins/search-exclude/

In order to make these modifications work, you need to modify the following file around line 289: class-rscsv_import_post_helper.php

Look for this code:

public function setObjectTerms($taxonomy, $terms)
{
$post = $this->getPost();

And replace with this code:

public function setObjectTerms($taxonomy, $terms)
{

//// MOD by jsherk //////////////////////////////////////////////////////////////////////////////////////

////////////// MULTIPLE terms for a TAXONOMY
// Check if taxonomy has more than one term (use | to specify multiple terms).
// For example import "tax_product_cat" as: "myCategory1|anotherCategory2" to add it to two categories.
// For example import "tax_product_visibility" as: "exclude-from-search|exclude-from-catalog" to hide from both shop catalog and search
$new_terms = array();
foreach ($terms as $term) {
$terms_split = false;
if (strpos($term, "|") == true ) {
$terms_split = true; // Yes the term contained multiple terms seperated by the pipe| character.
$split_terms = explode("|", $term);
foreach ($split_terms as $split_term ) {
// Add each split as a seperate term
$new_terms[] = $split_term;
}
}
if ($terms_split == false) {
// No the term did not contain multiple terms.
$new_terms[] = $term;
}
}
$terms = $new_terms; // Replace orignal terms with split up terms
//////////////

////////////// SEARCH EXCLUDE PLUGIN https://wordpress.org/plugins/search-exclude/
// If you use a plugin called SEARCH EXCLUDE then we need to create an OPTION instead of a TAXONOMY.
// In the csv file, use a csv header of "tax_search_exclude" and then set a value of either "yes" or "no". If the value is "yes" then we will add the option to the options table.
if ($taxonomy == "search_exclude") {
if (strtolower($terms[0]) == "yes") {
$server_path_array = explode("wp-content", __FILE__);
$server_path = $server_path_array[0];
$wp_load = $server_path.'wp-load.php';
require_once( $wp_load );
$wp_option = $server_path.'wp-includes/option.php';
require_once($wp_option);
$post = $this->getPost();
$new_option_id = intval($post->ID); // get the post_id
$search_exclude_options = get_option("sep_exclude"); // read the current values from the options table
if (empty($search_exclude_options)) {
// if the option is empty, then it does not exist and needs to be added
$new_search_exclude_option = array($new_option_id);
delete_option("sep_exclude"); // option may exist but be empty so we need to delete it first otherwise add_option will not update (add_option will only work if the option does not exist at all).
add_option("sep_exclude", $new_search_exclude_option, " ", "yes");
} else {
$search_exclude_options[] = $new_option_id;
update_option("sep_exclude", $search_exclude_options);
}
$search_exclude_options = get_option("sep_exclude"); // re-read the current values from the options table
}
}
//////////////

//// end MOD by jsherk //////////////////////////////////////////////////////////////////////////////////////

$post = $this->getPost();

Here is a sample CSV file with MODIFICATIONS you can copy and paste:

post_id,post_name,post_title,post_content,post_author,post_date,post_tags,post_category,post_thumbnail,post_type,post_status,_sku,_regular_price,_price,_stock,_manage_stock,_visibility,tax_search_exclude,tax_product_visibility,tax_product_type,tax_product_cat,_custom_field_hidden,custom_field_meta
"","my-first-product-url-slug","My first product name","description","","","","","https://mywordpresssite.com/wp-content/uploads/first-product-featured-image.jpg","product","publish","first-product-sku","50","50","3","yes","hidden","yes","exclude-from-search|exclude-from-catalog","simple","my-product-category|another-product-category","hidden meta field","meta field"
"","my-second-product-url","My second product name","description","","","","","https://mywordpresssite.com/wp-content/uploads/second-product-featured-image.jpg","product","publish","second-product-sku","20","20","4","yes","hidden","no","exclude-from-catalog","simple","another-product-category","hidden meta field","meta field"

Simple POS setup for WooCommerce – Point Of Sale plugins for WordPress

I was looking for a simple Point Of Sale (POS) solution that would allow me to take in-person Cash payments as well as Credit Card payments for my WooCommerce store.

There are several free POS plugins available that allow Cash payments, but you need to pay for the Pro versions if you also want to take Credit Cards as well.

There are also several free POS plugins that will allow you to take both Cash and Credit Card payments, but you need to use their credit processor and not your own.

The following is a very simple POS setup that will allow you to take both Cash payments on your WooCommerce store, as well as Credit Card payments using whatever credit card processor and gateway you already have setup.

There are a few issues that you need to be aware of if you are going to use this method:
(1) This setup assumes that you are currently NOT using the Cash On Delivery payment method in WooCommerce. If you are already using this payment method, then this setup will not work for you.
(2) This method will not calculate change due from cash tendered. You will manually need to do this.
(3) With this method, you can not split a payment as partial cash and partial credit card. It needs to be all cash or all credit card.

If those issues are not a problem for you, then below are the steps you need to set it up and make it work for you.

In summary, what we are going to do is add a new user with a new/unique user role called SHOP CASHIER. We will then make the Cash On Delivery method availble during the checkout process, but only if this user with SHOP CASHIER role is logged in. If any other user is logged in, or if no user is logged in, then the Cash On Delivery method will not be available.

STEP 1 – Install and Activate plugins
Install and activate the following two plugins:
Members (MemberPress) https://wordpress.org/plugins/members/
Payment Gateways by User Roles for WooCommerce (Imaginate Solutions) https://wordpress.org/plugins/payment-gateways-by-user-roles-for-woocommerce/

STEP 2 – Create a new role
Go to Members tab then to Roles.
Look for the Subscriber role, and click on CLONE.
Change the Cloned Role name to something like “SHOP CASHIER” and click on ADD ROLE.
NOTE: You can actually clone any role you want, but I chose the Subscriber role because my Shop Cashier does not need to access anything else within WordPress.
NOTE: The Members plugin has a setting (which is ON by default) that will allow you to assign multiple roles to the same user. You can disable this if would prefer to leave it the WordPress default way, where they can only be assigned a single role at a time.

STEP 3 – Add a new user with new role
Go to Users tab and then Add New.
Create a new user and assign them the new role of SHOP CASHIER and click ADD NEW USER.

STEP 4 – Set CASH ON DELIVERY as only availble to new role
Go to WooCommerce tab then to Settings then to Payment Gateways By User Roles.
Under the CASH ON DELIVERY method, click in the INCLUDE USER ROLES box and select the SHOP CASHIER role.
Scroll to bottom and click on SAVE CHANGES.

STEP 5 – Activate the Cash On Delivery payment method
Go to WooCommerce tab then to Settings then to Payments.
Click on the Set Up/Manage button for the Cash On Delivery method.
Check the box to ENABLE this method.
Set the title to something like: CASH
Set the description to something like: When customer has PAID in FULL with cash, click on PLACE ORDER.
Set the instructions to something like: Pay with cash, in-person.
Click on SAVE CHANGES.

STEP 6 – Test your changes
Now to test your setup, log out from WordPress and go to your WooCommerce store and add a product to your cart and the proceed to checkout.
Since you are logged out, you should NOT see the CASH method available. Only the regular payments methods that are normally available to your customers should be availble.
You can also try to login with any user except the new SHOP CASHIER user. When you log in with any other except the SHOP CASHIER user, you should still NOT see the CASH method available.
Now finally you want to login with the SHOP CASHIER user. When you proceed to checkout, you should now see the option for CASH available along with all your other regular payment methods, so you will be able to accept in-person cash payments as well as your any of your other payment methods.

How to convert Presearch tokens (PRE) to ETH (or BTC or cash) – PRE tokens

Presearch is working on a decentralized search engine: https://presearch.io/

Their crypto currency token is PRE

I have built up some PRE by using their search engine, and wanted to cash them out but found the process was not very easy because many exchanges do not accept PRE and therefore won’t exchanage it. So it took me several days to figure out how to do it.

STEP 1
Follow Presearchs own instruction by creating a wallet with My Ether Wallet (https://www.myetherwallet.com) and withdraw your tokens and send them to your new MEW wallet.

STEP 2
In order to exchange your PRE for something else, you will need to have some ETH in your MEW wallet to pay for the gas.
I found .005 ETH was a good minimum number.
You will need to purchase the ETH on another exchange and then send it to your MEW wallet.

STEP 3
NOTE: I recently noticed that CoinGetCoin.com website is no longer working. If you have alternative suggestion, please post in the comments.
You can then use CoinGetCoin to make the exchange (https://coingetcoin.com/#how-it-works).
You tell it how many PRE you will send, and it will tell you how many ETH you will get back.
I like this platform because you just send the PRE and it will automatically send ETH back to your wallet.
Specify the approximate amount of PRE you are going to send (does not need to be exact), and then specify the wallet address where you want the ETH sent after the exchange (I just sent it back to my MEW wallet).
CoinGetCoin will then give you a wallet address and you have 24 hours to send your PRE.
Be sure to note the minimum PRE that they will accept.

STEP 4
Go back to your MEW wallet and specify the address CoinGetCoin gave you, and send your PRE.
You can go back to CoinGetCoin and it will tell the progress (when it receives your PRE and when it sent the ETH back).
I have made a couple exchanges using CoinGetCoin and it took less than 30 minutes each time.

STEP 5
Now that you have ETH in your My Ether Wallet instead of PRE, you can do what you want with it.
For me, I sent it to my Coinsquare.com account and converted it to dollars and withdrew it to my bank account.

FREE codec for playing HEVC h.265 video on Windows 10

I was having an issue where my Windows 10 computer would not play HEVC h.265 video.

When you try to play the video, Windows Movies & TV app opens, but says it can not play it and that you need to purchase a $0.99 plugin from the Microsoft Store.

But there is actually a FREE version of codec that you can install/launch from the Microsoft Store as well (but of course they do not tell you about it).
Its called:

HEVC Video Extensions from Device Manufacturer
https://www.microsoft.com/en-us/p/hevc-video-extensions-from-device-manufacturer/9n4wgh0z6vhq

Alternate link:
https://www.microsoft.com/en-us/p/hevc-video-extensions-from-device-manufacturer/9n4wgh0z6vhq?irgwc=1&OCID=AID2000142_aff_7593_159229&tduid=%28ir__hwp9gz9pl9kftzgvkk0sohzize2ximz2ee93rrzl00%29%287593%29%28159229%29%28%29%28UUwpUdUnU56887YYwYg%29&irclickid=_hwp9gz9pl9kftzgvkk0sohzize2ximz2ee93rrzl00&activetab=pivot%3Aoverviewtab

Click the link above (its directly on Microsoft.com), choose GET, open the MICROSOFT STORE, choose INSTALL and then choose LAUNCH.
You do NOT need to sign up and do NOT need to create microsoft account to install this codec. Just skip/ignore any of those requests.

After this, try playing your HEVC h.265 videos with Windows Movies & TV app, and they should play!

Per Product Flat Rate Shipping for WooCommerce

Per Product Flat Rate Shipping for WC has just been released!

Set seperate flat-rate shipping costs for both Domestic and International shipping on a per product basis in WooCommerce.

This plugin will allow to set a flat-rate domestic shipping price and also a flat-rate international shipping price for each WooCommerce product that you have.

Find it here: https://wordpress.org/plugins/per-product-flat-rate-shipping-for-wc/

Automatically Rename Media On Upload Plugin

Automatically Rename Media on Upload plugin has just been released.

This plugin will automatically rename any media files you upload to the Media Library, by adding a prefix to the beginning of the filename based on the filetype.

For example, you can tell it to add the prefix “pic-” to the beginning of all .jpg files that you upload. So uploading an image called car.jpg would get renamed to pic-car.jpg

And since it changes the name of the file, it will also change the “slug” that wordpress uses based on this new name.

You can set an individual/unique prefix for each of the following filetypes:
jpg jpeg png bmp gif tif mp4 avi m4v mov flv mkv 3gp pdf doc docx xls xlsx ppt pptx mp3 ogg wav zip csv txt

You will need to go to the settings page and set the prefix you want to use for each of the filetypes.

The default behavior is that it will NOT rename any uploaded files until you have set the prefix on the settings page.

== Frequently Asked Questions ==

= Can I manually rename the files when I upload them? =
No. In the settings you can set how the filename will be renamed when it is uploaded. File will be automatically renamed during the upload process.

= Can I choose whether a file will be renamed when I upload it? =
No. In the settings you can set how the filename will be renamed when it is uploaded. File will be automatically renamed during the upload process.

= How do I disable renaming files of only certain types? =
On the settings page, you can remove the prefix from the textbox and set it empty/blank for any filetype that you do not want to be renamed when it is uploaded. If a particular filetype has an empty/blank textbox, then it will not be renamed when it is uploaded.

= How do I rename only files of one specific filetype, but not all the other filetypes? =
On the settings page, you can remove the prefix from the textbox and set it empty/blank for any filetype that you do not want to be renamed when it is uploaded. If a particular filetype has an empty/blank textbox, then it will not be renamed when it is uploaded.

= For what filetypes can I modify the prefix for the renaming of the file? =
You can set an individual/unique prefix for each of the following filetypes: jpg jpeg png bmp gif tif mp4 avi m4v mov flv mkv 3gp pdf doc docx xls xlsx ppt pptx mp3 ogg wav zip csv txt

= The filetype I need to rename is not listed. What can I do? =
Submit a support request and I will see if I can get that filetype added for you.

= I have uploaded a file to the Media Library, but it was not renamed? What happened? =
Make sure you go to the settings page and set the prefix you want to use for the particular filetype you are uploading and want renamed. And don’t forget to hit the SAVE button to make sure your changes are saved.

Shopify: How to add External Link Buy Now button and remove Add To Cart button

I have some products (eBooks) that are only available to purchase on Amazon so I needed a way to add a BUY NOW ON AMAZON button and also needed to remove the ADD TO CART button.

This solution requires an App that lets you add custom Metadata Fields to your products. I tested a few different free ones, and ended up going with Simple Admin https://apps.shopify.com/simple-meta

This solution also requires adding some custom code to your theme. In this example I am using the free theme called SIMPLE.

STEP 1
Add and install the Simple Admin app to your Shopify store.

STEP 2
Once installed, go to your Apps section and click on Simple Admin to go to its dashboard.

STEP 3
Click on PRODUCTS over in the top right corner.

STEP 4
Choose the product you want add the Buy Now External Link button too, and click the ID number of that product.

STEP 5
Click on the META tab.

STEP 6
Click ADD METAFIELD.

STEP 7
Enter the following information:
KEY: BuyNowText
VALUE: BUY NOW on Amazon.com
VALUE TYPE: String
NAMESPACE: CustomExternalLink
DESCRIPTION: The value is the text the customer will see on the button.
Click SAVE.

STEP 8
Click ADD METAFIELD again.

STEP 9
Enter the following information:
KEY: BuyNowLink
VALUE: https://anydomain.com/some/link/to/product
VALUE TYPE: String
NAMESPACE: CustomExternalLink
DESCRIPTION: Enter external link in the value field. To disable external link, enter the word “none” (without quotes) in the value field.
Click SAVE.

STEP 10
Now go to ONLINE STORE then THEMES then click on ACTIONS for your current theme and choose EDIT CODE.
NOTE: I am using the free SIMPLE theme.

STEP 11
Locate the SECTIONS / PRODUCT-TEMPLATE.LIQUID file and click on it so the file opens up in the editor.
NOTE: The following code that I am going to modify is specific to the SIMPLE theme and is located in the SECTIONS / PRODUCT-TEMPLATE.LIQUID file. The code you are looking for may be slightly different if you are using a different theme, and may also be located in a different file. Another file to check for the code would be the TEMPLATES / PRODUCT.LIQUID file.

STEP 12
Look for the following code:

<div class="product-single__cart-submit-wrapper{% if section.settings.enable_payment_button %} product-single__shopify-payment-btn{% endif %}{% if section.settings.add_to_cart_width == 'full_width' %} product-form--full{% endif %}">
  <button type="submit" name="add" id="AddToCart" class="btn product-single__cart-submit{% if section.settings.add_to_cart_width == 'full_width' %} btn--full{% endif %}{% if section.settings.enable_payment_button %} shopify-payment-btn btn--secondary{% endif %}">
    <span id="AddToCartText">{{ 'products.product.add_to_cart' | t }}</span>
  </button>
  {% if section.settings.enable_payment_button %}
    {{ form | payment_button }}
  {% endif %}
</div>

STEP 13
Replace the code above with this code:

{% comment %}
  MOD by Jeff - Wrapped the DIV with the IF-ELSE statement to show External BUY NOW button.
              - When link is found, the ADD TO CART and BUY NOW buttons will disappear and this button will show instead.
              - Use Simple Admin app to add custom metafields.
              - NAMESPACE: CustomExternalLink
              - KEY: BuyNowLink = enter http link to external site or the word "none" without quotes to disable
              - KEY: BuyNowText = the text you want customer to see
{% endcomment %}
{% if product.metafields.CustomExternalLink.BuyNowLink == blank or product.metafields.CustomExternalLink.BuyNowLink == 'none' %}
<div class="product-single__cart-submit-wrapper{% if section.settings.enable_payment_button %} product-single__shopify-payment-btn{% endif %}{% if section.settings.add_to_cart_width == 'full_width' %} product-form--full{% endif %}">
  <button type="submit" name="add" id="AddToCart" class="btn product-single__cart-submit{% if section.settings.add_to_cart_width == 'full_width' %} btn--full{% endif %}{% if section.settings.enable_payment_button %} shopify-payment-btn btn--secondary{% endif %}">
    <span id="AddToCartText">{{ 'products.product.add_to_cart' | t }}</span>
  </button>
  {% if section.settings.enable_payment_button %}
    {{ form | payment_button }}
  {% endif %}
</div>
{% else %}
  <a href="{{ product.metafields.CustomExternalLink.BuyNowLink }}"><button class="btn" style="background-color:black; pointer-events: none;"><span>{{ product.metafields.CustomExternalLink.BuyNowText }}</span></button></a>
{% endif %}
{% comment %}
  END MOD by Jeff
{% endcomment %}

STEP 14
Click SAVE.

STEP 15
Go view your product and you should see the new BUY NOW button has been added and the ADD TO CART button has been removed.

 

Enjoy!!!