Skip to content

Commit 861190c

Browse files
committed
Update readme/docs
1 parent e042549 commit 861190c

File tree

2 files changed

+103
-40
lines changed

2 files changed

+103
-40
lines changed

README.md

Lines changed: 96 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,124 @@
11
# WooCommerce External Product Embed
2-
This plugin provides a shortcode to embed products from another store on your site. It connects to another website running WooCommerce, and displays products from that site via the shortcodes provided.
2+
This plugin provides a shortcode to embed products from a separate store on your site. It connects to another website running WooCommerce, and displays products from that site through the use of a shortcode.
33

44
## Installation
5-
1. Choose "Download Zip" in the top right corner.
6-
2. Select "Add New" and then "Upload Plugin" starting at the Plugins page in WordPress.
7-
3. Activate the plugin.
5+
1. Go to the [releases tab](https://github.com/WPprodigy/woocommerce-external-product-embed/releases) in this repo.
6+
2. Find the "Latest release" and click to download `woocommerce-external-product-embed.zip`.
7+
3. Starting at the Plugins page in the WordPress Admin, select "Add New" and then "Upload Plugin".
8+
3. Upload and Activate the plugin.
89
3. Go to Settings > WooCommerce External Products.
9-
4. Add in the [credentials](http://docs.woothemes.com/document/woocommerce-rest-api/) to connect to external site.
10+
4. Add in the [credentials](https://docs.woocommerce.com/document/woocommerce-rest-api/) to connect to external site.
1011

1112
### A few notes about this plugin:
12-
* It requires an admin account for the website running WooCommerce.
13-
* It must make an authorized connection to the external site.
13+
* You must have an admin account for the website running WooCommerce, or access to WooCommerce API keys.
14+
* The external website must be using WooCommerce version 3.0 or later.
1415

15-
## Code Snippets
16-
* Manipulate the product data: https://gist.github.com/WPprodigy/afd0db56bf3f67379237
17-
* Add custom settings: https://gist.github.com/WPprodigy/96dbaeab8820cc85af42
16+
## Usage
17+
18+
The shortcode you can use to embed products onto your WordPress pages/posts is `[wcepe_products]`. Just using this shortcode on a page won't do anything though by default, you need add shortcode attributes to tell it what products you want to show.
19+
20+
You can show specific products by listing the IDs or SKUs like this:
21+
- `[wcepe_products ids='96,99']`
22+
- `[wcepe_products skus='sku1, sku2']`
23+
24+
You can show products from a specific category or categories by listing the category ID(s):
25+
- `[wcepe_products category='102,119']`
26+
27+
You can show product that are recently added, on sale, or featured like this:
28+
- `[wcepe_products recent=true]`
29+
- `[wcepe_products on_sale=true]`
30+
- `[wcepe_products featured=true]`
31+
32+
And best of all, you can combine any of the above! For example, you can show on-sale products from a specific category, or you can show featured products that are also on-sale.
33+
34+
There are some additional attributes that can also effect what is displayed.
35+
36+
- `orderby` - Can be set to title, menu_order, date, rand, or id.
37+
- `order` - Set to asc or desc.
38+
- `number` - Will determine how many products are shown.
39+
- `columns` - Determine how many columns should be when displayed.
40+
- `button` - Enter custom text for the "add to cart" button.
41+
- `hide` - List certain parts of the product display you would like to hide. Can be set to image, title, rating, onsale, price, and/or button.
42+
43+
An example shortcode using the above attributes would look like this:
44+
[wcepe_products orderby='title' order='desc' number='12' columns='4' hide='image,rating,onsale' number=12 button='View Product']
45+
46+
You of course don't need to type all of that out every time. Here are the default settings for each attribute, along with the options:
47+
48+
```
49+
'orderby' => 'title', // title, menu_order, date, rand, or id.
50+
'order' => 'desc', // asc or desc
51+
'number' => 12,
52+
'columns' => '4', // 1-6
53+
'recent' => false,
54+
'on_sale' => false,
55+
'featured' => false,
56+
'hide' => '', // image, title, rating, onsale, price, and/or button
57+
'button' => 'View Product',
58+
59+
'ids' => '', // Comma separated IDs
60+
'skus' => '', // Comma separated SKUs
61+
'category' => '', // Comma separated category IDs
62+
```
63+
64+
Note that some attributes can contradict each other. For example, using a list of `ids` and `skus` in the same shortcode will result in products only showing if both an ID and a SKU match for it.
1865

1966
## Frequently Asked Questions
2067

21-
#### What are the shortcodes for this plugin?
22-
* `[external_product id='99']`
23-
* `[recent_external_products number='10']`
68+
#### What about the old shortcodes?
69+
`[external_product]` and `[recent_external_products]` have been deprecated. They should still work on version 3.0, but you can't use many of the above options and eventually they will be removed from the plugin.
2470

2571
#### Where do I get the "consumer_key" and "consumer_secret"
26-
[How to generate API keys](http://docs.woothemes.com/document/woocommerce-rest-api/)
72+
Here is a guide on [how to generate API keys](https://docs.woocommerce.com/document/woocommerce-rest-api/)
2773

28-
#### Can I control what gets displayed by the shortcode?
29-
There are quite a few attributes that can be added to the shortcode. The only required attribute is "id" for the 'external_product' shortcode. Here is an example of all the attributes available for each shortcode:
74+
#### How can I edit the html output?
75+
You can copy the file in this plugin located at `templates/product-content.php`, and paste it into the root of your child theme like this: `child-theme-name/wcepe/product-content.php`. Then you can edit this file to your liking.
3076

31-
* `[external_product id="99,22" image="show" title="show" price="show" rating="show" button="Custom Text Here"]`
32-
* `[recent_external_products number="4" image="show" title="show" price="show" rating="show" button="Custom Text Here"]`
77+
The `wcepe_products_loop_wrapper_open` and `wcepe_products_loop_wrapper_open` filters may also be of use if you are customizing the HTML.
3378

34-
Adding "hide" to any of those attributes will hide that element, including the button.
79+
#### Where can I find the Product ID or Category ID?
80+
To find the Product ID, go to the products page in WooCommerce, hover over the product and the ID will appear as seen [here](http://cld.wthms.co/1RbKGK).
3581

36-
#### Can I add multiple products per shortcode?
37-
Yep! `[external_product id="10,11,12,13,14,15"]`
82+
To find the Category ID, go to Products > Categories and click "Edit" for a specific category. Then look in page's URL for `tag_ID=X`, where X is the category ID. Here is [an example](http://cld.wthms.co/1Tgp0W).
3883

39-
#### How can I edit the html output?
40-
You can copy the file in this plugin located at `templates/shortcodes/external-product-single.php`, and paste it into the root of your child theme like so: `child-theme-name/woocommerce-external-product-embed/shortcodes/external-product-single.php`. Then you can edit this file to your liking.
84+
#### Why don't the products look good on my website?
85+
I tried my best to replicate WooCommerce's default styling, but ultimately it is impossible to be compatible with all WordPress themes. So you may need to customize the CSS some.
4186

42-
#### Where can I find the Product "ID" field?
43-
To find the Product ID, go to the products page in WooCommerce, hover over the product and the ID will appear as shown below.
44-
![How to find the product ID](http://docs.woothemes.com/wp-content/uploads/2012/01/Find-Product-ID-in-WooCommerce-950x281.png)
87+
When WooCommerce is also enabled on the website where this plugin is installed, I disable the plugin's stylesheet so WooCommerce can take over the styling. You can also disable the stylesheet and use only your own styles if you would like to.
4588

46-
## Basic Debugging
89+
## Common Problems
4790
Here are a few steps you can take if things don't seem to be working.
4891

49-
1. Make sure the shortcode is not using "smart quotes". Keep them dumb. tl;dr - smart quotes are evil. To fix this, go to the Text Editor in WordPress and retype all of the quotes.
92+
1. Make sure you aren't using "smart quotes" in the shortcode. To fix this, go to the Text Editor in WordPress and retype all of the quotation marks.
93+
94+
2. If the display looks incorrect, make sure you did not embed the shortcode between `<pre>` tags. To remove these tags, edit the page and click on the "Text Editor" like in the above step.
5095

51-
2. If the display looks incorrect, make sure you did not embed the shortcode between `<pre>` tags. To remove these tags, edit the page, and click on the "Text Editor" like in the above step.
96+
3. Ensure the external website has the REST API enabled at WooCommerce > Settings > API.
5297

53-
3. There may be a plugin or theme conflict on the site running WooCommerce that is interferring with the API. The best way to test this is to disable all plugins and switch to a default theme temporarily on the WooCommerce website.
98+
4. There may be a plugin or theme conflict on the site running WooCommerce that is interferring with the REST API. The best way to test this is to disable all plugins and switch to a default theme temporarily on the WooCommerce website. Or, you can try connecting to another demo/staging site for a quick test.
5499

55-
4. It is possible that the web host is not allowing remote connections to be made. You can contact your host and ask if this is the case.
100+
## Customizations: Code Snippets & Hooks/Filters
101+
* Manipulate the product data: Coming Soon
102+
* Hooks/Filters Reference: Coming Soon
103+
104+
## Development
105+
If you want to work on the master branch of this plugin and submit a PR, you'll need to use Composer to get the WC API - PHP Client dependency.
106+
107+
1. Install [Composer](https://getcomposer.org/).
108+
2. In terminal, cd into this plugin's directory.
109+
3. Run `composer install`.
56110

57111
## Changelog
112+
= 3.0 =
113+
* New shortcode with many more options: [wcepe_products]
114+
* Exponential performance improvements.
115+
* Better error handling in both the admin and on the frontend.
116+
* Switched to using official WC PHP Library.
117+
* Updated to the newest version of the WooCommerce API, v2.
118+
* Only make one API call per shortcode, not per product.
119+
* Only create one transient per shortcode, not per product.
120+
* Updated frontend styles.
121+
58122
= 2.0 =
59123
* Feature - New shortcode: [recent_external_products]
60124
* Feature - Added extensibility throughout the whole plugin.
@@ -66,5 +130,4 @@ Here are a few steps you can take if things don't seem to be working.
66130
* Initial Release!
67131

68132
## Upgrade Notice
69-
= 2.0 =
70-
2.0 is a major rewrite. More efficient, faster, and comes with a new shortcode! The previous shortcodes will still work, but the admin settings will be lost. So when updating, be sure to head over to the settings in order to re-enter the API details.
133+
3.0 is a major rewrite. The previous shortcodes will still work, but the template has changed. If you made customizations to the template, you will need to switch to using the new template file and folder structure.

classes/class-wcepe-shortcodes.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,18 @@ public static function products( $atts ) {
118118
}
119119

120120
$default_atts = apply_filters( 'wcepe_default_products_atts', array(
121-
'orderby' => 'title',
122-
'order' => 'desc',
121+
'orderby' => 'title', // title, menu_order, date, rand, or id.
122+
'order' => 'desc', // asc or desc
123123
'number' => 12,
124124
'per_page' => 0, // Will override 'number'
125-
'columns' => '4',
126-
'ids' => '', // Comma seperated IDs
127-
'skus' => '', // Comma seperated SKUs
128-
'category' => '', // Comma seperated category IDs
125+
'columns' => '4', // 1-6
126+
'ids' => '', // Comma separated IDs
127+
'skus' => '', // Comma separated SKUs
128+
'category' => '', // Comma separated category IDs
129129
'recent' => false,
130130
'on_sale' => false,
131131
'featured' => false,
132-
'hide' => '', // image, title, rating, onsale, price, or button
132+
'hide' => '', // image, title, rating, onsale, price, and/or button
133133
'button' => __( 'View Product', 'woocommerce-external-product-embed' ) // Button text
134134
) );
135135

0 commit comments

Comments
 (0)