Coder Social home page Coder Social logo

woocommerce-external-product-embed's Introduction

WooCommerce External Product Embed

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.

Here is a screenshot of the products being displayed on the frontend and the settings in the backend.

Installation

  1. Go to the releases tab in this repo.
  2. Find the "Latest release" and click to download woocommerce-external-product-embed.zip.
  3. Starting at the Plugins page in the WordPress Admin, select "Add New" and then "Upload Plugin".
  4. Upload and Activate the plugin.
  5. Go to Settings > WooCommerce External Products.
  6. Add in the credentials to connect to external site.

A few notes about this plugin:

  • You must have an admin account for the website running WooCommerce, or access to WooCommerce API keys.
  • The external website must be using WooCommerce version 3.0 or later.

Usage

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 will need to add attributes to tell the shortcode what products you want to show.

You can show specific products by listing the IDs or SKUs like this:

  • [wcepe_products ids='96,99']
  • [wcepe_products skus='sku1, sku2']

You can show products from a specific category or categories by listing the category ID(s):

  • [wcepe_products category='102,119']

You can show product that are recently added, on sale, or featured like this:

  • [wcepe_products recent=true]
  • [wcepe_products on_sale=true]
  • [wcepe_products featured=true]

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.

There are some additional attributes that can also effect what is displayed.

  • orderby - Can be set to title, menu_order, date, rand, or id.
  • order - Set to asc or desc.
  • number - Will determine how many products are shown.
  • columns - Determine how many columns should be when displayed.
  • button - Enter custom text for the "add to cart" button.
  • 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.

An example shortcode using the above attributes would look like this:

  • [wcepe_products orderby='title' order='desc' number='12' columns='4' hide='image,rating,onsale' number=12 button='View Product']

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:

'orderby'  => 'title', // title, menu_order, date, rand, or id.
'order'    => 'desc', // asc or desc
'number'   => 12,
'columns'  => '4', // 1-6
'recent'   => false,
'on_sale'  => false,
'featured' => false,
'hide'     => '', // image, title, rating, onsale, price, and/or button
'button'   => 'View Product',

'ids'      => '', // comma separated IDs
'skus'     => '', // comma separated SKUs
'category' => '', // comma separated category IDs

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.

Frequently Asked Questions

What about the old shortcodes?

[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.

Where do I get the "consumer_key" and "consumer_secret"

Here is a guide on how to generate API keys

How can I edit the html output?

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.

The wcepe_products_loop_wrapper_open and wcepe_products_loop_wrapper_open filters may also be of use if you are customizing the HTML.

Where can I find the Product ID or Category ID?

To find the Product ID, go to the products page in WooCommerce, hover over the product and the ID will appear as seen here.

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.

Why don't the products look good on my website?

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.

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.

Common Problems

Here are a few steps you can take if things don't seem to be working.

  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.

  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.

  3. Ensure the external website has the REST API enabled at WooCommerce > Settings > API.

  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.

Customizations: Code Snippets & Hooks/Filters

  • Manipulate the product data: Coming Soon
  • Hooks/Filters Reference: Coming Soon

Development

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.

  1. Install Composer.
  2. In terminal, cd into this plugin's directory.
  3. Run composer install.

Changelog

= 3.0 =

  • New shortcode with many more options: [wcepe_products]
  • Exponential performance improvements.
  • Better error handling in both the admin and on the frontend.
  • Switched to using official WC PHP Library.
  • Updated to the newest version of the WooCommerce API, v2.
  • Only make one API call per shortcode, not per product.
  • Only create one transient per shortcode, not per product.
  • Updated frontend styles.

= 2.0 =

  • Feature - New shortcode: [recent_external_products]
  • Feature - Added extensibility throughout the whole plugin.
  • Tweak - Combined all product-related data into a single transient.
  • Tweak - Reworked the admin page for a cleaner interface.
  • Tweak - Updated to the new WooCommerce API.

= 1.0 =

  • Initial Release!

Upgrade Notice

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.

woocommerce-external-product-embed's People

Contributors

tlshadowrex avatar wpprodigy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

woocommerce-external-product-embed's Issues

critical error on multi site

I wanted to use this to show products from other sites to main site, i running wp multi site with sub directories, and followed the instruction when activating on main site all i get is a message that says... critical error occured, please check you inbox.

I never got any email, i created the rest api on the other site as mentined and add it to new the disire site (main site)

Fatal error on Woocommerce 3.5.x

when inserting the shortcode the post breaks with the following fatal error message:

Fatal error: Uncaught Error: Class 'Automattic\WooCommerce\Client' not found in /var/www/webroot/ROOT/wp-content/plugins/woocommerce-external-product-embed-master/classes/class-wcepe-api-client.php:35 Stack trace: #0 /var/www/webroot/ROOT/wp-content/plugins/woocommerce-external-product-embed-master/classes/class-wcepe-api-client.php(63): WCEPE_API_Client->connect() #1 /var/www/webroot/ROOT/wp-content/plugins/woocommerce-external-product-embed-master/classes/class-wcepe-data-store.php(65): WCEPE_API_Client->get_products(Array) #2 /var/www/webroot/ROOT/wp-content/plugins/woocommerce-external-product-embed-master/classes/class-wcepe-data-store.php(56): WCEPE_Data_Store->save_loop_products() #3 /var/www/webroot/ROOT/wp-content/plugins/woocommerce-external-product-embed-master/classes/class-wcepe-shortcodes.php(84): WCEPE_Data_Store->get_loop_products() #4 /var/www/webroot/ROOT/wp-content/plugins/woocommerce-external-product-embed-master/classes/class-wcepe-shortcodes.php(195): WCEPE_Shortcodes::product_loop(Array, Array) #5 / in /var/www/webroot/ROOT/wp-content/plugins/woocommerce-external-product-embed-master/classes/class-wcepe-api-client.php on line 35

Feature request: make $opening, $closing and $default_atts overridable from within product-content.php

Firstly - I just love your plugin as it saved me of inventing the wheel myself (and writing plugins like these are not my daily cup of tea so to speak)!

During my implementation I experienced the need to tailor the $opening and $closing sections so it blends nicely in within the theme I use (and use case). The same is also applicable for the $default_atts. All 3 variables are within class-wcepe-shortcodes.php.

Would it be possible to make those 3 variable overridable from the product-content.php file which one can add to the (child) theme folder?

Thanks!

--

Some background on my use case: I'm overhauling a Multisite installation for a group of whisky enthusiasts who buy some casks together. The website is split into 3 sections, each with it's own purpose: 1) main info + Newsletter, 2) the WC shop, 3) a wpForo forum. Within the main info site I use wcepe to display a summary of the products (cask info, mostly product attributes). Within the wpForo forum I use it to include a table with all the product (cask) details to the first post of a topic. So in both cases the template and the defaults are different.

Columns not filled correctly

I want to show multiple products categories on one page. But the first row is not filled totally.

these are the shortcodes that I'm using.
[wcepe_products category='46' hide='button, price' order='asc' number='26' columns='5' ]
[wcepe_products category='272' hide='button, price' order='asc' number='26' columns='5' ]

GORDIJNEN-

https://tinyurl.com/2mdkt4p5

Feature request: post_author

If you can add a post_author query, then you can also start hooking into WC Vendors for multi vendor marketplaces. Quite a useful feature to add. Simply doing post_author="xx" where xx is ID, and you'd make a lot of our members happy. :-)

inventory management

how does this plugin deal with inventory? does it remove the item from the master's woocommerce inventory?

Issues with Column Display

Hello

We are using this plugin to fetch certain category data into another website, but is not supporting additional attributes. The main attribute we are using is column with data in 3 columns. Also want to ask, if there is any provison to show pagination?

Thank You

issue in data fetching

i add all the process but not fetching values
Here is the link

here is my code (Edit: redacted)

please resolve the issue
thanks

Feature: Product Category Shortcode

Our use is constantly timing out. I imagine it is because we are trying to load 20+ products via single embed code. The best solution I imagine would be a way to get an entire category instead of doing products individually, this would reduce the query to the remote server significantly than 20+ separate API requests.

Not Working Anymore

Hi Caleb,

Just wanted to let you know that this plugin has stopped working, since the recent update of WOOCOMMERCE. It shows nothing anymore.

Regards,

Error after activation

After activation I get the following error:

mepages/u16211/anhaenger.craftmax.com/wp-content/plugins/woocommerce-external-product-embed-master/vendor/autoload.php): failed to open stream: No such file or directory in /homepages/u16211/anhaenger.craftmax.com/wp-content/plugins/woocommerce-external-product-embed-master/woocommerce-external-product-embed.php on line 54

Warning: include_once(): Failed opening '/homepages/u16211/anhaenger.craftmax.com/wp-content/plugins/woocommerce-external-product-embed-master/vendor/autoload.php' for inclusion (include_path='.:/vrmd/webserver/php-7.3.26/lib/php') in /homepages/u16211/anhaenger.craftmax.com/wp-content/plugins/woocommerce-external-product-embed-master/woocommerce-external-product-embed.php on line 54

What can I do?

Upgrade to WC REST API v3

v3 of the WC REST API is out for a while already so perhaps it's an idea to switch over to that one. I tested it by changing it in the WCEPE_API_Client to 'version' => 'wc/v3', and all is still working fine as far as I can see.

And perhaps it's also an idea to add 'query_string_auth' => true to the line below it. This line could be commented out with the remark that it's needed when using HTTPS.

So that would make it like:

	private function connect() {
		$settings = get_option( 'wcepe_settings' );
		$options  = [
			'wp_api' => true,
			'version' => 'wc/v3',
			# 'query_string_auth' => true  /* uncomment when using WCEPE over HTTPS */
		];

Vendor folder

I am trying your plugin, but in file "woocommerce-external-product-embed.php" on line "54" it wants to include "/vendor/autoload.php" but this is no located in the repo. As a result we cannot run it without errors. Or am I doing something wrong? Thanks in advance!

Orderby='rand' problem

Hi there,

When I put a shortcode like the following in a page, it shows nothing.
[wcepe_products category='36' orderby='rand']
But when I change the orderly attribute to something else like title or date, it starts displaying products again.

I have got two more questions but I don't know if this is the right place to ask them or not, if not please advise where I should ask them.

  1. Is it possible to display products from a specific attribute like pa_brand for example?
  2. Is it possible to exclude out-of-stock products?

Many Thanks,

Sanitize the product permalink w/ esc_url_raw()

Hi there,

Thanks for this awesome plugin. I installed it today and it looks great. The only problem is that all the permalinks start with three extra dashes (---) that make links return a 404.

Could you please look into this problem.

Many Thanks

Broken on Woocommerce 3.x

Hi.
The plugin is broken on Woocommerce 3 version.

Diaplays an error 500 and doesn't render post content.
Coudl you fix it?

Strange behavior

Hi Caleb. I took a second shot at testing your plugin together with a multilingual Woo store. Result: partial success and partial disaster ;-).

Success: Apparently something has happened with the Woo Rest API as I could now access products also in other languages than site default (which was the initial problem I had). Happy, happy!

However, I managed to do this exactly one time, after that the remote page (where your plugin is installed) totally broke down. What exactly happens is that the page HTML renders up to your plugin but no further and the page totally freezes (seems to Javascipt is loaded either, for instance to top admin bar is not shown on the page. The page can be seen here: http://sail-in-finland.info/product-test/.

At the point where the HTML stops is your shortcode.

Site is WP 4.4.2, Woo not installed, remote site is WP 4.4.2 also and WC 2.5, both with Comet cache. I've tested also with the Cache cleared, does not seem to be related to that. I've reset the REST credentials a number of times, the remote site does not see the REST call so looks like the problem is on the side the plugin?

The site is experiencing technical difficulties.

Hi!

If I add a shortcode to a page the page breaks and I get the message "The site is experiencing technical difficulties." I tried it on another WordPress installation but same issue.

What could be the reason for that?

multicurrency eshop.

Hi is it somehow possible to change the default eshop currency for displayed products? i have the multidomain, multilanguage and multicurrency shop setup with polylang, woocomerce polylang integration and other plugin for currency switch on frontend, but those settings are not displayed for api call.

it would be easiest to set the currency shortcode in shortcode call for example, but how.

Feature request: category name or slug compatible filters on shortcode

Hi, as soon as the fatal error bugs are resolved I'd like to display products from certain categories on varied pages of my website. The names of the categories of the 2 wordpress installs I created equal (only with "ID" can not do that), so it would be very useful if the plugin's shortcode allowed to use the full category slug, so I can show the products on the pages that have some relation.

Example: [wcepe_products category='sports,goods-from-china']

Feature Request: Affiliate ID in Links

This would be awesome if in the Settings we could add the Affiliate ID to the end of all product URLs. This way we could have affiliate use this on their websites so we can control the content form our main site!

Language problem

My external woocommerce shop is in Spanish.

When I display the products on an external website it shows the buttons VIEW PRODUCT and SALE in English.

How can I solve this?

Pull data from multiple woocommerce sites?

Is it possible to pull product data from more then 1 source?

I have 3 wordpress / woocommerce sites and would like to add the latest products from all three onto a 4th wordpress site... They would need to be seperate so I can display them on different pages etc (site A products on page1, site B products on page2 etc)

How easy would this be?

Filter by category or tag

Hi.
Is it possible to add shortcodes in order to add external products filtering by product category or product tag?

Uncaught Error: Class 'Automattic\WooCommerce\Client' not found

Hi
I get error when trying to use a plugin. I use WordPress version 5.7.1

Une erreur de type E_ERROR a été causée dans la ligne 33 du fichier /home/bwt/webapps/BWT/wp-content/plugins/woocommerce-external-product-embed-master/classes/class-wcepe-api-client.php. Message d’erreur : Uncaught Error: Class 'Automattic\WooCommerce\Client' not found in /home/bwt/webapps/BWT/wp-content/plugins/woocommerce-external-product-embed-master/classes/class-wcepe-api-client.php:33
Stack trace:
#0 /home/bwt/webapps/BWT/wp-content/plugins/woocommerce-external-product-embed-master/classes/class-wcepe-api-client.php(45): WCEPE_API_Client->connect()
#1 /home/bwt/webapps/BWT/wp-content/plugins/woocommerce-external-product-embed-master/classes/class-wcepe-admin.php(240): WCEPE_API_Client->test_connection()
#2 /home/bwt/webapps/BWT/wp-includes/class-wp-hook.php(292): WCEPE_Admin::test_api_connection()
#3 /home/bwt/webapps/BWT/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters()
#4 /home/bwt/webapps/BWT/wp-includes/plugin.php(484): WP_Hook->do_action()
#5 /home/bwt/webapps/BWT/wp-content/plugins/woocommerce-external-product-embed-master/classes/class-wcepe-admin.php(199): do_action()
#6 /home/bwt/webapps/BWT/wp-includes/class-wp-hook.php(292): WCEPE_Admin::wcepe_options_page()
#7 /home/bwt/webapps/BWT/

error on saving settings

Log:

Fatal error: Uncaught Error: Class 'Automattic\WooCommerce\Client' not found in /wp-content/plugins/woocommerce-external-product-embed-master/classes/class-wcepe-api-client.php:35

multi store

Hi, I need to connect different stores in different pages, is it possible to put the parameters of the API KEYS in the shorcode?

Error when entering credentials

Hi,

First of, this looks like a great plugin, but im having a big problem with it.

When I enter the API credentials into the settings page of your plugin, it produces this error upon saving them: API Connection Error. Check the Consumer Secret.

screen shot 2017-12-16 at 19 20 09

The site running Woocommerce is currently on the latest release.

To troubleshoot, I have done the following:

Revoked & regenerated API Keys.
Uninstalled & reinstalled your plugin.

Please can you help me with a fix?

API Connection Error. Check the Store URL and ensure the REST API is enabled on the external site.

Please help.
Everything worked fine with this plugin until we updated SSL cert on the remote site where the products are being pulled from.

I have generated new API Key & Secret, but when I save I get this error:
"API Connection Error. Check the Store URL and ensure the REST API is enabled on the external site."

I can however access _https://mydomain.co.za/wp-json/ with a normal get request via POSTMAN using the same API Key and Secret.

Any help would be greatly appreciated!

Product Description Request

Is there any way you can choose to show the product description as well for each product? I've been trying to use the REST API hooks for woocommerce but am coming up short.

Feature Request - More options for displaying products

I have been looking for a plugin like this for ages, so that I can display products from my store to other sites that I run. I have managed to get it working on my site and it works great. I have found however that the [external_product] shortcode only works when i specify a product id, which is great for promoting a specific product or products. I have a lot of products and want to have more options for displaying different types of products from my woo store.

Is there a way to add the following features to give more options for displaying products?

  • Display random products from the woo store,
  • Display products from a specific category
  • Display products with reviews / specific rating
  • Display on sale products
  • Don't display out of stock products.

Publish to wordpress.org for better auto updating !

  • Please make it available on wordpress.org

  • Bring back random products selecting back:
    fetch product with 'ramdom' rather than 'on_sale/featured/recent'
    and orderby='rand' is not working !

Thank you, WPprodigy!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.