WordPress
Manage blog and store content with WordPress CMS
MedusaWP
MedusaWP enables you to use WordPress as a headless CMS or as a storefront for your Medusa shop.
MedusaWP is a powerful tool that seamlessly integrates your Medusa e-commerce store with WordPress, offering a range of features to simplify your e-commerce management. We also provide a rich set of Medusa-oriented functions for you to utilize within your WordPress theme.
You can connect to your existing Medusa store and effortlessly import its data into WordPress. You have full visibility into the sync progress and can easily troubleshoot any issues that may arise during the synchronization process. Data health checks ensure that your synced items are error-free and successfully imported into WordPress. Managing media assets is a breeze with the ability to import Medusa thumbnails directly into the WordPress Media Library. You can also manage and display Medusa data as custom post types within your WordPress site.
For a seamless shopping experience, the plugin automatically creates a cart for customers who land on your site. A country switcher functionality is also included, allowing cart region updates based on the selected country code.
When needed, you can remove all synced data and disconnect from Medusa effortlessly.
Unlock the full potential of your Medusa store with the MedusaWP plugin and streamline your e-commerce operations.
Features
- Use WordPress as a headless CMS or as a storefront for the Medusa shop.
- Connect to an existing Medusa store from WordPress and import its data into WordPress.
- Synchronize your Medusa e-commerce data with WordPress.
- Import Medusa thumbnails into the WordPress Media Library (either directly when syncing Medusa data or separately).
- Provide an overview and troubleshooting for the sync progress.
- Check the data health, including identifying any sync errors, partially synced items, or successfully synced data.
- Manage and display Medusa data (products, product collections...) in WordPress as custom post types (CPT).
- Automatically create a cart when the customer lands on the site for the first time (default country/region settings can be configured within the WordPress plugin settings).
- Implement a country switcher that updates the cart region based on the given country code.
- Remove all synced data.
- Disconnect from Medusa.
- Expose a rich set of functions available for you to use within your WordPress theme, including Copy to clipboard
medusa-react
utility functions for computing and formatting prices and amounts.
Prerequisites
- Medusa Backend
- Redis
- WordPress Installation
- WordPress website up and running
- Administrator access to your WordPress website
- PHP Composer latest version 1.x
How To Install
Medusa Plugin
- In the root of your Medusa backend, run the following command to install the Copy to clipboard
medusa-plugin-wordpress
plugin:
1npm i medusa-plugin-wordpress
- Add the plugin to your Copy to clipboard
medusa-config.js
file at the end of the Copy to clipboardplugins
array:
12345678910111213module.exports = {// ...plugins: [// ...{resolve: "medusa-plugin-wordpress",options: {// ...},},],// ...}
- Next, configure the Copy to clipboard
medusa-plugin-wordpress
plugin that you added in the previous step. For example:
123456789101112131415const plugins = [// ...{resolve: `medusa-plugin-wordpress`,options: {sync_options: {attempts: 5,backoff: {type: 'exponential',delay: 2000}}},},]
Configuration Options
The plugin can be configured with the following options:
12345678(property) sync_options: {delay?: number | undefined;attempts: number;backoff?: {type: "fixed" | "exponential";delay: number;} | undefined;}
- Copy to clipboard
sync_options
- Sync options object.- Copy to clipboard
delay
- Delay time in milliseconds, default Copy to clipboardundefined
. - Copy to clipboard
attempts
- Number of attempts, default Copy to clipboard3
. - Copy to clipboard
backoff
- Backoff options object.- Copy to clipboard
type
- Backoff type, either Copy to clipboard"fixed"
or Copy to clipboard"exponential"
, default Copy to clipboard"exponential"
. - Copy to clipboard
delay
- Backoff delay time in milliseconds, default Copy to clipboard2000
.
- Copy to clipboard
- Copy to clipboard
WordPress Plugin
- In the root directory of your WordPress installation, run the following command to install the plugin using Composer:
1composer require agilo/medusawp
- Log in to your WordPress admin dashboard using your administrator credentials.
- After successful installation, click the "Activate" button to activate the plugin.
- To finish the plugin setup, proceed to the How To Use steps.
How To Use
- Run the following command in the directory of the Medusa backend to run the backend:
1npm run start
- After you have logged into your WordPress site, navigate to the MedusaWP plugin settings page, which can be found in the WordPress admin menu.
- Connect your Medusa e-commerce store and your WordPress instance. On the default MedusaWP plugin screen enter your Medusa shop URL and credentials - email and password and press "Connect" button.
[!NOTE] If necessary, you can always disconnect from your Medusa shop by opening a dropdown in the upper-right corner, pressing the "Disconnect" button, and confirming your decision.
- When the connection with Medusa is established, sync your Medusa e-commerce data with WordPress by clicking the "Sync" button. You can also choose to import Medusa thumbnails into the WordPress Media Library directly with the data sync (this may slightly slow down your data sync process), or you can import thumbnails separately later using the "Import" button.
[!NOTE] It is possible to remove all your synced Medusa data from your WordPress site at any time using the "Remove" button. We recommend that you backup your data before proceeding with this action.
- Once the data synchronization is complete, configure the default settings of the MedusaWP plugin to suit your needs. In the dropdown, you can select the default country, which will be used to automatically create a cart in the corresponding region when a customer lands on the site.
- Verify that the plugin is working as expected by visiting your website and using its features.
That's it! You have successfully installed and set up the MedusaWP plugin. Enjoy using it in your projects and on your WordPress website.
Contributing
We welcome contributions from the community to help make this project even better. Please feel free to open pull requests or issues. Thank you for considering contributing, and we look forward to collaborating with you!
Below you can find the plugin development guide that will help you get started with running MedusaWP in your local environment.
Plugin Development
Prerequisites
- Docker and Docker Compose
- We suggest using OrbStack on Mac.
- Node.js v20
- PHP Composer latest version 1.x | 2.x
After you have installed the requirements, you will need to add a host entry for the project by appending the following line to your Copy to clipboard/etc/hosts
file:
1127.0.0.1 medusawp.test
Running Locally
Follow these step-by-step instructions to run the project locally:
- Fulfill everything mentioned in the prerequisites above
- Copy to clipboard
git clone https://github.com/Agilo/medusawp.git
- clone the repo - Copy to clipboard
cd medusawp
- position into the project directory - Copy to clipboard
cp .env.example .env
- set up docker-compose environment variables - Copy to clipboard
cp ./dev/medusa/.env.example ./dev/medusa/.env
- set up Medusa environment variables - Copy to clipboard
npm i
- install all dependencies - Copy to clipboard
npm run addcert -w wordpress
- add a self-signed certificate for Copy to clipboardmedusawp.test
- Copy to clipboard
npm run build -w wordpress
- build WordPress - Copy to clipboard
composer install -d ./wordpress-plugin
- install Composer dependencies for the WordPress plugin - Copy to clipboard
docker-compose --profile wp --profile medusa up
- start WordPress and Medusa Docker containers - Open a new terminal tab
- Copy to clipboard
npm run seed -w medusa
- seed Medusa DB - Copy to clipboard
npm run migrate -w medusa
- run Medusa migrations - Copy to clipboard
npm start
- build the Medusa plugin and start the Medusa dev server and Medusa plugin watcher
WordPress is now available at https://medusawp.test and Medusa Admin dashboard at http://localhost:9000/app.
Default credentials for Medusa Admin are:
12admin@medusa-test.comsupersecret
Default credentials for WordPress are:
12adminadmin
Available Commands
- Copy to clipboard
npm start
- build the plugin and start the Medusa dev server and plugin watcher - Copy to clipboard
npm run build -w medusa-plugin-wordpress
- build the Medusa plugin - Copy to clipboard
npm run watch -w medusa-plugin-wordpress
- start the Medusa plugin watcher - Copy to clipboard
npm run test -w medusa-plugin-wordpress
- run Medusa plugin tests - Copy to clipboard
npm run seed -w medusa
- seed Medusa DB - Copy to clipboard
npm run build -w medusa
- build Medusa - Copy to clipboard
npm run migrate -w medusa
- run Medusa migrations - Copy to clipboard
npm start -w medusa
- start the Medusa development server - Copy to clipboard
npm run addcert -w wordpress
- add a self-signed certificate for Copy to clipboardmedusawp.test
- Copy to clipboard
npm run build -w wordpress
- build WordPress
Docker Services
Docker services are defined in Copy to clipboarddocker-compose.yml
file. There are 2 separate profiles defined in the file:
- Copy to clipboard
wp
- WordPress - Copy to clipboard
medusa
- Medusa
Most of the time, you will want to run both profiles at the same time. But if you want to run only one of them, you can do so by running Copy to clipboarddocker-compose --profile <profile> up
. For example, to start only WordPress, you would run Copy to clipboarddocker-compose --profile wp up
.
WordPress
- Copy to clipboard
nginx
- Nginx web server that serves WordPress on https://medusawp.test - Copy to clipboard
php
- PHP-FPM - Copy to clipboard
db
- MariaDB database server for WordPress available on localhost:3306, you can change credentials and port in Copy to clipboard.env
file - Copy to clipboard
phpmyadmin
- phpMyAdmin available on http://localhost:8080
Medusa
- Copy to clipboard
postgres
- PostgreSQL database server for Medusa available on localhost:5432, you can change credentials and port in Copy to clipboard.env
and Copy to clipboarddev/medusa/.env
files - Copy to clipboard
pgadmin
- pgAdmin available on http://localhost:5050 - Copy to clipboard
redis
- Redis server for Medusa available on localhost:6379 - Copy to clipboard
admin
- Medusa Admin available on http://localhost:9000
Additional Resources
- Medusa Documentation
- Medusa Development Documentation
- WordPress Documentation
- WordPress Developer Resources
License
This project is licensed under the MIT License.
Credits
MedusaWP is developed and maintained by AGILO. Huge thanks to all contributors.