Skip to content

ultramarine256/onshop

Repository files navigation

OnShop E-commerce App

Welcome to the OnShop repository! This project is focused on providing a modern, feature-rich e-commerce backend using WordPress and WooCommerce. The goal is to create a solid foundation for building a fast and user-friendly shopping experience for your customers with the frontend technology of your choice.

Features

  • WordPress backend for easy content management and product catalog updates
  • WooCommerce integration for powerful e-commerce functionality
  • RESTful API for seamless data exchange with frontend applications
  • Product search, filter, and pagination
  • User authentication and account management
  • Shopping cart and checkout functionality
  • Flexible and extensible for custom features

Development

Development with docker

Install and setup docker desktop. To have project running on local with docker will be created 2 containers

  • create mysql dump for test database with all setup for wordpress
  • ensure that all datetime fields has 1000-01-01 00:00:00 as minimal datetime value instead of 0000-00-00 00:00:00 or reconfigure your mysql docker to allow another datetime range
  • put dump as seeds.sql in ./src/api/db-seeds/ dir
  • add _config.json in ./src/api/ dir with structure:
{
  "dbhost": "db-onshop",
  "dbname": "<DB_NAME>",
  "dbusername": "<DB_USER_NAME>", // for dev use root
  "dbpassword": "<DB_PASSWORD>",
  "use-debug": true
}
  • use the same creds in docker container env for db-onshop container in docker-compose.yml
  • run docker-compose up --build in ./src/api/.docker from project root dir
  • if docker db setup done you will be able to see wp login page on http://localhost:8202/wp-admin

Authorization

To make api authorization work properly you need:

  • install composer
  • install jwt-auth with composer composer require firebase/php-jwt
  • set auth configs under _config.json
  "auth": {
    "secret-sign-key": "YOUR_SECRET_SIGN_KEY",
    "secret-enc-key": "YOUR_SECRET_ENC_KEY",
    "issuer-claim": "YOUR_ISSUER_CLAIM",
    "audience-claim": "THE_AUDIENCE",
    "token-validation-delay-sec": 0,
    "token-expiration-interval-sec": 1800
  },
  • ensure apache propagate auth headers with
<IfModule mod_rewrite.c>
RewriteEngine On
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</IfModule>

in .htaccess config file

  • on every success request token will be re-issued with new expiration time, you will get it with OS_Bearer response header

API Endpoints

The WooCommerce REST API provides several endpoints to interact with your store's data. Here are some examples:

  • List all products: https://your-wordpress-url.com/wp-json/wc/v3/products
  • Retrieve a specific product: https://your-wordpress-url.com/wp-json/wc/v3/products/{id}
  • List product categories: https://your-wordpress-url.com/wp-json/wc/v3/products/categories
  • Create an order: https://your-wordpress-url.com/wp-json/wc/v3/orders

For a comprehensive list of available endpoints and detailed documentation, visit the WooCommerce REST API documentation.

Support

If you encounter any issues or have questions, please feel free to open an issue on GitHub or contact the maintainers directly.

Acknowledgements

  • The WordPress team for creating a powerful and versatile CMS
  • The WooCommerce team for providing a comprehensive e-commerce solution
  • All the open-source developers whose packages and libraries are used in this project