Changeset 3077903
- Timestamp:
- 04/27/2024 04:27:25 AM (21 months ago)
- Location:
- headless-wc
- Files:
-
- 11 added
- 3 edited
-
docs/index.html (modified) (1 diff)
-
docs/swagger-ui-3.52.5.css (added)
-
docs/swagger-ui-bundle-3.52.5.js (added)
-
docs/swagger-ui-standalone-preset-3.52.5.js (added)
-
tags/1.0.2 (added)
-
tags/1.0.2/api (added)
-
tags/1.0.2/api/v1 (added)
-
tags/1.0.2/api/v1/cart.php (added)
-
tags/1.0.2/api/v1/order.php (added)
-
tags/1.0.2/headless-wc.php (added)
-
tags/1.0.2/license.txt (added)
-
tags/1.0.2/readme.txt (added)
-
trunk/headless-wc.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
headless-wc/docs/index.html
r3077902 r3077903 1 1 <html> 2 2 <head> 3 <script src=" https://unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script>4 <script src=" https://unpkg.com/swagger-ui-dist@3/swagger-ui-standalone-preset.js"></script>5 <link rel="stylesheet" type="text/css" href=" https://unpkg.com/swagger-ui-dist@3/swagger-ui.css" />3 <script src="./swagger-ui-bundle-3.52.5.js"></script> 4 <script src="./swagger-ui-standalone-preset-3.52.5.js"></script> 5 <link rel="stylesheet" type="text/css" href="./swagger-ui-3.52.5.css" /> 6 6 <title>HeadlessWC</title> 7 7 </head> 8 8 <body> 9 9 <div id="swagger-ui"></div> 10 <script defer>11 window.onload = function () {12 const ui = SwaggerUIBundle({13 url: "https://dawidw5219.github.io/headless-wc/openapi.yaml",14 dom_id: "#swagger-ui",15 deepLinking: true,16 presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],17 plugins: [SwaggerUIBundle.plugins.DownloadUrl],18 layout: "StandaloneLayout",19 });20 window.ui = ui;21 };22 </script>10 <script defer> 11 window.onload = function () { 12 const ui = SwaggerUIBundle({ 13 url: "https://dawidw5219.github.io/headless-wc/openapi.yaml", 14 dom_id: "#swagger-ui", 15 // deepLinking: false, 16 // presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset], 17 // plugins: [SwaggerUIBundle.plugins.DownloadUrl], 18 // layout: "StandaloneLayout", 19 }); 20 window.ui = ui; 21 }; 22 </script> 23 23 <style> 24 * { 25 padding: 0; 26 margin: 0; 27 } 28 .topbar, 29 img, 30 .try-out__btn { 31 display: none !important; 32 } 24 33 /* .swagger-ui .topbar .download-url-wrapper input[type="text"] { 25 34 border: 2px solid #77889a; -
headless-wc/trunk/headless-wc.php
r3077886 r3077903 3 3 * Plugin Name: HeadlessWC: Ultimate eCommerce Decoupler 4 4 * Description: Custom WC endpoints for headless checkout 5 * Version: 1.0. 25 * Version: 1.0.3 6 6 * Author: Dawid Wiewiórski 7 7 * License: GPLv2 or later … … 16 16 function headlesswc_check_woocommerce_active() 17 17 { 18 include_once (ABSPATH . 'wp-admin/includes/plugin.php');18 include_once (ABSPATH . 'wp-admin/includes/plugin.php'); 19 19 if (!class_exists('WooCommerce')) { 20 20 if (is_plugin_active(plugin_basename(__FILE__))) { -
headless-wc/trunk/readme.txt
r3077902 r3077903 1 1 === HeadlessWC: Ultimate eCommerce Decoupler === 2 2 Contributors: dawidw11 3 Tags: woocommerce, headless, decoupled,cart, rest-api3 Tags: woocommerce, headless, cart, rest-api 4 4 Requires at least: 5.1 5 5 Tested up to: 6.4.3 … … 15 15 16 16 [API Documentation](https://dawidw5219.github.io/headless-wc/) 17 18 ## Cart Endpoint19 20 This endpoint is designed to manage the shopping cart for a WC store via a WordPress plugin. It allows for adding products to the cart, applying a coupon code, and retrieving cart details including products, totals, available shipping, and payment methods.21 22 **Request**23 24 - **URL**: `/wp-json/headless-wc/v1/cart`25 - **Type**: `POST`26 - **Content-Type**: `application/json`27 - **Body**:28 - `cart`: An array of objects where each object represents a product. Each product object must have:29 - `id` (required): The product ID.30 - `quantity` (optional, default is 1): The quantity of the product.31 - `couponCode` (optional): A string representing a coupon code to apply to the cart.32 33 **Response**34 35 - **Success Response Code**: `200 OK`36 - **Error Response Code**: `500 Internal Server Error` (In case of an unexpected error)37 - **Body**:38 - `success`: A boolean indicating if the request was successful.39 - `products`: An array of objects representing the products in the cart, including details such as product ID, name, image URLs, quantity, price, sale information, and totals.40 - `subtotal`: The cart subtotal before taxes, shipping, and discounts.41 - `total`: The final total of the cart after all taxes, shipping, and discounts.42 - `taxTotal`: The total amount of taxes.43 - `shippingTotal`: The total shipping cost.44 - `discountTotal`: The total discount amount applied from coupons.45 - `couponCode`: The coupon code applied, if any.46 - `currency`: The currency used for the cart totals.47 - `availableShippingMethods`: An array of available shipping methods, including details such as method name, ID, price, tax, and zone information.48 - `availablePaymentMethods`: An array of available payment methods, including details such as method ID, title, and description.49 50 **Notes**51 52 - The cart will be emptied before adding the new items specified in the request.53 - If a product ID or quantity is invalid, it will be skipped.54 - The currency and totals are retrieved based on the WC settings.55 - Shipping and payment methods are determined based on the store's configuration and the current state of the cart.56 57 ## Order Endpoint58 59 This endpoint is designed to create and process a new order in a WC store through a WordPress plugin. It involves order creation, applying shipping methods, coupons, and setting payment methods based on the provided request data.60 61 **Request**62 63 - **Type**: `POST`64 - **URL**: `/wp-json/headless-wc/v1/order`65 - **Content-Type**: `application/json`66 - **Body Parameters**:67 - `cart`: An array of objects, each representing a product to be added to the order. Each product object should include:68 - `id` (required): The product ID.69 - `quantity` (optional, default is 1): The quantity of the product.70 - `furgonetkaPoint` (optional): A custom field for specifying a pickup point.71 - `furgonetkaPointName` (optional): A name for the specified pickup point.72 - `redirect_url` (required): A URL to redirect the client after payment is made.73 - `shipping_method_id` (required): The ID of the shipping method to apply to the order.74 - `coupon_code` (optional): A coupon code to apply to the order.75 - `payment_method_id` (required): The ID of the payment method for the order.76 - `total` (required): The total amount the client expects to pay.77 - `use_different_shipping` (optional): A flag to indicate whether a different shipping address should be used.78 79 **Response**80 81 - **Success Response Code**: `200 OK`82 - **Error Response Codes**:83 - `400 Bad Request` for missing or invalid data such as no valid redirect URL, invalid products, invalid shipping method, invalid payment method, or total mismatch.84 - `500 Internal Server Error` for unexpected errors.85 - **Body**:86 - `success`: A boolean indicating the request was successful.87 - `orderId`: The ID of the created order.88 - `paymentUrl`: A URL to where the client should be redirected to make the payment.89 90 **Notes**91 92 - Orders are initially created with a `pending` status and marked as having accepted terms.93 - The `redirect_url` is essential for redirecting clients after payment.94 - Valid products must be specified in the `cart` array to proceed with the order creation.95 - Shipping and billing addresses are set based on the provided data, with the option to specify different shipping information.96 - The endpoint validates the shipping method, applies any provided coupon code, and sets the specified payment method.97 - The order's total is verified against the client's expected total to prevent mismatches.98 - If any validation fails (such as invalid shipping method, payment method, or total mismatch), the created order is deleted to maintain data integrity.99 17 100 18 == Installation ==
Note: See TracChangeset
for help on using the changeset viewer.