├── .editorconfig ├── .github └── workflows │ └── deploy.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.sh ├── deploy.sh ├── font-selection.json └── source ├── fonts ├── slate.eot ├── slate.svg ├── slate.ttf ├── slate.woff └── slate.woff2 ├── images ├── favicon-180x180.png ├── favicon-192x192.png ├── favicon-270x270.png ├── favicon-32x32.png ├── logo.png ├── navbar.png ├── woocommerce-api-key-generated.png ├── woocommerce-api-keys-settings.png ├── woocommerce-auth-endpoint-example.png ├── woocommerce-auth-endpoint-flow.png └── woocommerce-creating-api-keys.png ├── includes ├── v1 │ └── _docs.md ├── v2 │ ├── _coupons.md │ ├── _customers.md │ ├── _index.md │ ├── _introduction.md │ ├── _orders.md │ ├── _products.md │ ├── _reports.md │ └── _webhooks.md ├── v3 │ ├── _authentication-endpoint.md │ ├── _coupons.md │ ├── _customers.md │ ├── _index.md │ ├── _introduction.md │ ├── _order-notes.md │ ├── _order-refunds.md │ ├── _orders.md │ ├── _product-attribute-terms.md │ ├── _product-attributes.md │ ├── _product-categories.md │ ├── _product-shipping-classes.md │ ├── _product-tags.md │ ├── _products.md │ ├── _reports.md │ ├── _tax-classes.md │ ├── _taxes.md │ └── _webhooks.md ├── wp-api-v1 │ ├── _authentication.md │ ├── _coupons.md │ ├── _customers.md │ ├── _index.md │ ├── _introduction.md │ ├── _order-notes.md │ ├── _order-refunds.md │ ├── _orders.md │ ├── _product-attribute-terms.md │ ├── _product-attributes.md │ ├── _product-categories.md │ ├── _product-shipping-classes.md │ ├── _product-tags.md │ ├── _products.md │ ├── _reports.md │ ├── _tax-classes.md │ ├── _taxes.md │ └── _webhooks.md ├── wp-api-v2 │ ├── _authentication.md │ ├── _coupons.md │ ├── _customers.md │ ├── _index.md │ ├── _introduction.md │ ├── _order-notes.md │ ├── _order-refunds.md │ ├── _orders.md │ ├── _payment-gateways.md │ ├── _product-attribute-terms.md │ ├── _product-attributes.md │ ├── _product-categories.md │ ├── _product-shipping-classes.md │ ├── _product-tags.md │ ├── _product-variations.md │ ├── _products.md │ ├── _reports.md │ ├── _setting-options.md │ ├── _settings.md │ ├── _shipping-methods.md │ ├── _shipping-zone-locations.md │ ├── _shipping-zone-methods.md │ ├── _shipping-zones.md │ ├── _system-status-tools.md │ ├── _system-status.md │ ├── _tax-classes.md │ ├── _taxes.md │ └── _webhooks.md └── wp-api-v3 │ ├── _authentication.md │ ├── _coupons.md │ ├── _customers.md │ ├── _data.md │ ├── _index.md │ ├── _introduction.md │ ├── _order-actions.md │ ├── _order-notes.md │ ├── _order-refunds.md │ ├── _orders.md │ ├── _payment-gateways.md │ ├── _product-attribute-terms.md │ ├── _product-attributes.md │ ├── _product-categories.md │ ├── _product-custom-fields.md │ ├── _product-reviews.md │ ├── _product-shipping-classes.md │ ├── _product-tags.md │ ├── _product-variations.md │ ├── _products.md │ ├── _refunds.md │ ├── _reports.md │ ├── _setting-options.md │ ├── _settings.md │ ├── _shipping-methods.md │ ├── _shipping-zone-locations.md │ ├── _shipping-zone-methods.md │ ├── _shipping-zones.md │ ├── _system-status-tools.md │ ├── _system-status.md │ ├── _tax-classes.md │ ├── _taxes.md │ └── _webhooks.md ├── index.html.md ├── javascripts ├── all.js ├── all_nosearch.js ├── app │ ├── _lang.js │ ├── _search.js │ └── _toc.js └── lib │ ├── _energize.js │ ├── _imagesloaded.min.js │ ├── _jquery.highlight.js │ ├── _jquery.js │ └── _lunr.js ├── layouts └── layout.erb ├── stylesheets ├── _api-endpoint.scss ├── _content.scss ├── _icon-font.scss ├── _label.scss ├── _lang-selector.scss ├── _normalize.scss ├── _rtl.scss ├── _toc.scss ├── _variables.scss ├── _warning.scss ├── print.css.scss └── screen.css.scss ├── v1.html.md ├── v2.html.md ├── v3.html.md ├── wp-api-v1.html.md └── wp-api-v2.html.md /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # Top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | indent_style = space 11 | indent_size = 2 12 | trim_trailing_whitespace = true 13 | 14 | [*.rb] 15 | charset = utf-8 16 | 17 | [*.md] 18 | trim_trailing_whitespace = false 19 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy on push 2 | on: 3 | push: 4 | branches: 5 | - trunk 6 | jobs: 7 | build-and-deploy: 8 | if: github.repository_owner == 'woocommerce' 9 | name: Build and deploy 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout code 13 | uses: actions/checkout@v2 14 | - name: Build 15 | run: ./build.sh 16 | - name: Deploy to GitHub Pages 17 | if: success() 18 | uses: crazy-max/ghaction-github-pages@v2 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | with: 22 | target_branch: gh-pages 23 | build_dir: build 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | coverage 6 | InstalledFiles 7 | lib/bundler/man 8 | pkg 9 | rdoc 10 | spec/reports 11 | test/tmp 12 | test/version_tmp 13 | tmp 14 | *.DS_STORE 15 | build/ 16 | .cache 17 | .vagrant 18 | .sass-cache 19 | 20 | # YARD artifacts 21 | .yardoc 22 | _yardoc 23 | doc/ 24 | .idea/ 25 | 26 | test.* 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008-2013 Concur Technologies, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | not use this file except in compliance with the License. You may obtain 5 | a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | License for the specific language governing permissions and limitations 13 | under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WooCommerce REST API Docs # 2 | 3 | Repository of documentation REST API WooCommerce. 4 | 5 | This project is based on [Slate](https://github.com/tripit/slate). 6 | 7 | ## Usage ## 8 | 9 | ### Updating and building the docs 10 | 11 | The docs for the latest version of the REST API (v3) are in `source/includes/wp-api-v3`. Each section of the docs has its own Markdown file. Once you have made changes, you can generate the docs locally with the following: 12 | 13 | ```bash 14 | ./build.sh 15 | ``` 16 | 17 | After the build script has finished, the generated docs can be found in the `build` directory. Open the `index.html` file in your browser to view the local version of the docs site. 18 | 19 | ### Deploying the docs 20 | 21 | When you merge a PR to the trunk branch of this repository, a workflow runs that will automatically deploy the generated docs to the `gh-pages` branch. However, you can also deploy manually with the following: 22 | 23 | ```bash 24 | ./deploy.sh 25 | ``` 26 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -o errexit # Abort if any command fails 3 | 4 | rm -rf build 5 | docker run --rm --name slate -v $(pwd)/build:/srv/slate/build -v $(pwd)/source:/srv/slate/source slatedocs/slate 6 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -o errexit #abort if any command fails 3 | me=$(basename "$0") 4 | 5 | help_message="\ 6 | Usage: $me [-c FILE] [] 7 | Deploy generated files to a git branch. 8 | 9 | Options: 10 | 11 | -h, --help Show this help information. 12 | -v, --verbose Increase verbosity. Useful for debugging. 13 | -e, --allow-empty Allow deployment of an empty directory. 14 | -m, --message MESSAGE Specify the message used when committing on the 15 | deploy branch. 16 | -n, --no-hash Don't append the source commit's hash to the deploy 17 | commit's message. 18 | " 19 | 20 | parse_args() { 21 | # Set args from a local environment file. 22 | if [ -e ".env" ]; then 23 | source .env 24 | fi 25 | 26 | # Parse arg flags 27 | # If something is exposed as an environment variable, set/overwrite it 28 | # here. Otherwise, set/overwrite the internal variable instead. 29 | while : ; do 30 | if [[ $1 = "-h" || $1 = "--help" ]]; then 31 | echo "$help_message" 32 | return 0 33 | elif [[ $1 = "-v" || $1 = "--verbose" ]]; then 34 | verbose=true 35 | shift 36 | elif [[ $1 = "-e" || $1 = "--allow-empty" ]]; then 37 | allow_empty=true 38 | shift 39 | elif [[ ( $1 = "-m" || $1 = "--message" ) && -n $2 ]]; then 40 | commit_message=$2 41 | shift 2 42 | elif [[ $1 = "-n" || $1 = "--no-hash" ]]; then 43 | GIT_DEPLOY_APPEND_HASH=false 44 | shift 45 | else 46 | break 47 | fi 48 | done 49 | 50 | # Set internal option vars from the environment and arg flags. All internal 51 | # vars should be declared here, with sane defaults if applicable. 52 | 53 | # Source directory & target branch. 54 | deploy_directory=build 55 | deploy_branch=gh-pages 56 | 57 | #if no user identity is already set in the current git environment, use this: 58 | default_username=${GIT_DEPLOY_USERNAME:-deploy.sh} 59 | default_email=${GIT_DEPLOY_EMAIL:-} 60 | 61 | #repository to deploy to. must be readable and writable. 62 | repo=origin 63 | 64 | #append commit hash to the end of message by default 65 | append_hash=${GIT_DEPLOY_APPEND_HASH:-true} 66 | } 67 | 68 | main() { 69 | parse_args "$@" 70 | 71 | enable_expanded_output 72 | 73 | if ! git diff --exit-code --quiet --cached; then 74 | echo Aborting due to uncommitted changes in the index >&2 75 | return 1 76 | fi 77 | 78 | commit_title=`git log -n 1 --format="%s" HEAD` 79 | commit_hash=` git log -n 1 --format="%H" HEAD` 80 | 81 | #default commit message uses last title if a custom one is not supplied 82 | if [[ -z $commit_message ]]; then 83 | commit_message="publish: $commit_title" 84 | fi 85 | 86 | #append hash to commit message unless no hash flag was found 87 | if [ $append_hash = true ]; then 88 | commit_message="$commit_message"$'\n\n'"generated from commit $commit_hash" 89 | fi 90 | 91 | previous_branch=`git rev-parse --abbrev-ref HEAD` 92 | 93 | if [ ! -d "$deploy_directory" ]; then 94 | echo "Deploy directory '$deploy_directory' does not exist. Aborting." >&2 95 | return 1 96 | fi 97 | 98 | # must use short form of flag in ls for compatibility with macOS and BSD 99 | if [[ -z `ls -A "$deploy_directory" 2> /dev/null` && -z $allow_empty ]]; then 100 | echo "Deploy directory '$deploy_directory' is empty. Aborting. If you're sure you want to deploy an empty tree, use the --allow-empty / -e flag." >&2 101 | return 1 102 | fi 103 | 104 | if git ls-remote --exit-code $repo "refs/heads/$deploy_branch" ; then 105 | # deploy_branch exists in $repo; make sure we have the latest version 106 | 107 | disable_expanded_output 108 | git fetch --force $repo $deploy_branch:$deploy_branch 109 | enable_expanded_output 110 | fi 111 | 112 | # check if deploy_branch exists locally 113 | if git show-ref --verify --quiet "refs/heads/$deploy_branch" 114 | then incremental_deploy 115 | else initial_deploy 116 | fi 117 | 118 | restore_head 119 | } 120 | 121 | initial_deploy() { 122 | git --work-tree "$deploy_directory" checkout --orphan $deploy_branch 123 | git --work-tree "$deploy_directory" add --all 124 | commit+push 125 | } 126 | 127 | incremental_deploy() { 128 | #make deploy_branch the current branch 129 | git symbolic-ref HEAD refs/heads/$deploy_branch 130 | #put the previously committed contents of deploy_branch into the index 131 | git --work-tree "$deploy_directory" reset --mixed --quiet 132 | git --work-tree "$deploy_directory" add --all 133 | 134 | set +o errexit 135 | diff=$(git --work-tree "$deploy_directory" diff --exit-code --quiet HEAD --)$? 136 | set -o errexit 137 | case $diff in 138 | 0) echo No changes to files in $deploy_directory. Skipping commit.;; 139 | 1) commit+push;; 140 | *) 141 | echo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to master, use: git symbolic-ref HEAD refs/heads/master && git reset --mixed >&2 142 | return $diff 143 | ;; 144 | esac 145 | } 146 | 147 | commit+push() { 148 | set_user_id 149 | git --work-tree "$deploy_directory" commit -m "$commit_message" 150 | 151 | disable_expanded_output 152 | #--quiet is important here to avoid outputting the repo URL, which may contain a secret token 153 | git push --quiet $repo $deploy_branch 154 | enable_expanded_output 155 | } 156 | 157 | #echo expanded commands as they are executed (for debugging) 158 | enable_expanded_output() { 159 | if [ $verbose ]; then 160 | set -o xtrace 161 | set +o verbose 162 | fi 163 | } 164 | 165 | #this is used to avoid outputting the repo URL, which may contain a secret token 166 | disable_expanded_output() { 167 | if [ $verbose ]; then 168 | set +o xtrace 169 | set -o verbose 170 | fi 171 | } 172 | 173 | set_user_id() { 174 | if [[ -z `git config user.name` ]]; then 175 | git config user.name "$default_username" 176 | fi 177 | if [[ -z `git config user.email` ]]; then 178 | git config user.email "$default_email" 179 | fi 180 | } 181 | 182 | restore_head() { 183 | if [[ $previous_branch = "HEAD" ]]; then 184 | #we weren't on any branch before, so just set HEAD back to the commit it was on 185 | git update-ref --no-deref HEAD $commit_hash $deploy_branch 186 | else 187 | git symbolic-ref HEAD refs/heads/$previous_branch 188 | fi 189 | 190 | git reset --mixed 191 | } 192 | 193 | filter() { 194 | sed -e "s|$repo|\$repo|g" 195 | } 196 | 197 | sanitize() { 198 | "$@" 2> >(filter 1>&2) | filter 199 | } 200 | 201 | main "$@" 202 | -------------------------------------------------------------------------------- /font-selection.json: -------------------------------------------------------------------------------- 1 | { 2 | "IcoMoonType": "selection", 3 | "icons": [ 4 | { 5 | "icon": { 6 | "paths": [ 7 | "M438.857 73.143q119.429 0 220.286 58.857t159.714 159.714 58.857 220.286-58.857 220.286-159.714 159.714-220.286 58.857-220.286-58.857-159.714-159.714-58.857-220.286 58.857-220.286 159.714-159.714 220.286-58.857zM512 785.714v-108.571q0-8-5.143-13.429t-12.571-5.429h-109.714q-7.429 0-13.143 5.714t-5.714 13.143v108.571q0 7.429 5.714 13.143t13.143 5.714h109.714q7.429 0 12.571-5.429t5.143-13.429zM510.857 589.143l10.286-354.857q0-6.857-5.714-10.286-5.714-4.571-13.714-4.571h-125.714q-8 0-13.714 4.571-5.714 3.429-5.714 10.286l9.714 354.857q0 5.714 5.714 10t13.714 4.286h105.714q8 0 13.429-4.286t6-10z" 8 | ], 9 | "attrs": [], 10 | "isMulticolor": false, 11 | "tags": [ 12 | "exclamation-circle" 13 | ], 14 | "defaultCode": 61546, 15 | "grid": 14 16 | }, 17 | "attrs": [], 18 | "properties": { 19 | "id": 100, 20 | "order": 4, 21 | "prevSize": 28, 22 | "code": 58880, 23 | "name": "exclamation-sign", 24 | "ligatures": "" 25 | }, 26 | "setIdx": 0, 27 | "iconIdx": 0 28 | }, 29 | { 30 | "icon": { 31 | "paths": [ 32 | "M585.143 786.286v-91.429q0-8-5.143-13.143t-13.143-5.143h-54.857v-292.571q0-8-5.143-13.143t-13.143-5.143h-182.857q-8 0-13.143 5.143t-5.143 13.143v91.429q0 8 5.143 13.143t13.143 5.143h54.857v182.857h-54.857q-8 0-13.143 5.143t-5.143 13.143v91.429q0 8 5.143 13.143t13.143 5.143h256q8 0 13.143-5.143t5.143-13.143zM512 274.286v-91.429q0-8-5.143-13.143t-13.143-5.143h-109.714q-8 0-13.143 5.143t-5.143 13.143v91.429q0 8 5.143 13.143t13.143 5.143h109.714q8 0 13.143-5.143t5.143-13.143zM877.714 512q0 119.429-58.857 220.286t-159.714 159.714-220.286 58.857-220.286-58.857-159.714-159.714-58.857-220.286 58.857-220.286 159.714-159.714 220.286-58.857 220.286 58.857 159.714 159.714 58.857 220.286z" 33 | ], 34 | "attrs": [], 35 | "isMulticolor": false, 36 | "tags": [ 37 | "info-circle" 38 | ], 39 | "defaultCode": 61530, 40 | "grid": 14 41 | }, 42 | "attrs": [], 43 | "properties": { 44 | "id": 85, 45 | "order": 3, 46 | "name": "info-sign", 47 | "prevSize": 28, 48 | "code": 58882 49 | }, 50 | "setIdx": 0, 51 | "iconIdx": 2 52 | }, 53 | { 54 | "icon": { 55 | "paths": [ 56 | "M733.714 419.429q0-16-10.286-26.286l-52-51.429q-10.857-10.857-25.714-10.857t-25.714 10.857l-233.143 232.571-129.143-129.143q-10.857-10.857-25.714-10.857t-25.714 10.857l-52 51.429q-10.286 10.286-10.286 26.286 0 15.429 10.286 25.714l206.857 206.857q10.857 10.857 25.714 10.857 15.429 0 26.286-10.857l310.286-310.286q10.286-10.286 10.286-25.714zM877.714 512q0 119.429-58.857 220.286t-159.714 159.714-220.286 58.857-220.286-58.857-159.714-159.714-58.857-220.286 58.857-220.286 159.714-159.714 220.286-58.857 220.286 58.857 159.714 159.714 58.857 220.286z" 57 | ], 58 | "attrs": [], 59 | "isMulticolor": false, 60 | "tags": [ 61 | "check-circle" 62 | ], 63 | "defaultCode": 61528, 64 | "grid": 14 65 | }, 66 | "attrs": [], 67 | "properties": { 68 | "id": 83, 69 | "order": 9, 70 | "prevSize": 28, 71 | "code": 58886, 72 | "name": "ok-sign" 73 | }, 74 | "setIdx": 0, 75 | "iconIdx": 6 76 | }, 77 | { 78 | "icon": { 79 | "paths": [ 80 | "M658.286 475.429q0-105.714-75.143-180.857t-180.857-75.143-180.857 75.143-75.143 180.857 75.143 180.857 180.857 75.143 180.857-75.143 75.143-180.857zM950.857 950.857q0 29.714-21.714 51.429t-51.429 21.714q-30.857 0-51.429-21.714l-196-195.429q-102.286 70.857-228 70.857-81.714 0-156.286-31.714t-128.571-85.714-85.714-128.571-31.714-156.286 31.714-156.286 85.714-128.571 128.571-85.714 156.286-31.714 156.286 31.714 128.571 85.714 85.714 128.571 31.714 156.286q0 125.714-70.857 228l196 196q21.143 21.143 21.143 51.429z" 81 | ], 82 | "width": 951, 83 | "attrs": [], 84 | "isMulticolor": false, 85 | "tags": [ 86 | "search" 87 | ], 88 | "defaultCode": 61442, 89 | "grid": 14 90 | }, 91 | "attrs": [], 92 | "properties": { 93 | "id": 2, 94 | "order": 1, 95 | "prevSize": 28, 96 | "code": 58887, 97 | "name": "icon-search" 98 | }, 99 | "setIdx": 0, 100 | "iconIdx": 7 101 | } 102 | ], 103 | "height": 1024, 104 | "metadata": { 105 | "name": "slate", 106 | "license": "SIL OFL 1.1" 107 | }, 108 | "preferences": { 109 | "showGlyphs": true, 110 | "showQuickUse": true, 111 | "showQuickUse2": true, 112 | "showSVGs": true, 113 | "fontPref": { 114 | "prefix": "icon-", 115 | "metadata": { 116 | "fontFamily": "slate", 117 | "majorVersion": 1, 118 | "minorVersion": 0, 119 | "description": "Based on FontAwesome", 120 | "license": "SIL OFL 1.1" 121 | }, 122 | "metrics": { 123 | "emSize": 1024, 124 | "baseline": 6.25, 125 | "whitespace": 50 126 | }, 127 | "resetPoint": 58880, 128 | "showSelector": false, 129 | "selector": "class", 130 | "classSelector": ".icon", 131 | "showMetrics": false, 132 | "showMetadata": true, 133 | "showVersion": true, 134 | "ie7": false 135 | }, 136 | "imagePref": { 137 | "prefix": "icon-", 138 | "png": true, 139 | "useClassSelector": true, 140 | "color": 4473924, 141 | "bgColor": 16777215 142 | }, 143 | "historySize": 100, 144 | "showCodes": true, 145 | "gridSize": 16, 146 | "showLiga": false 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /source/fonts/slate.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/fonts/slate.eot -------------------------------------------------------------------------------- /source/fonts/slate.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Generated by IcoMoon 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /source/fonts/slate.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/fonts/slate.ttf -------------------------------------------------------------------------------- /source/fonts/slate.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/fonts/slate.woff -------------------------------------------------------------------------------- /source/fonts/slate.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/fonts/slate.woff2 -------------------------------------------------------------------------------- /source/images/favicon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/images/favicon-180x180.png -------------------------------------------------------------------------------- /source/images/favicon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/images/favicon-192x192.png -------------------------------------------------------------------------------- /source/images/favicon-270x270.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/images/favicon-270x270.png -------------------------------------------------------------------------------- /source/images/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/images/favicon-32x32.png -------------------------------------------------------------------------------- /source/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/images/logo.png -------------------------------------------------------------------------------- /source/images/navbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/images/navbar.png -------------------------------------------------------------------------------- /source/images/woocommerce-api-key-generated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/images/woocommerce-api-key-generated.png -------------------------------------------------------------------------------- /source/images/woocommerce-api-keys-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/images/woocommerce-api-keys-settings.png -------------------------------------------------------------------------------- /source/images/woocommerce-auth-endpoint-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/images/woocommerce-auth-endpoint-example.png -------------------------------------------------------------------------------- /source/images/woocommerce-auth-endpoint-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/images/woocommerce-auth-endpoint-flow.png -------------------------------------------------------------------------------- /source/images/woocommerce-creating-api-keys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/woocommerce/woocommerce-rest-api-docs/304659615cf8175f5d7d0a0cd67238dd5e5ce913/source/images/woocommerce-creating-api-keys.png -------------------------------------------------------------------------------- /source/includes/v2/_reports.md: -------------------------------------------------------------------------------- 1 | # Reports # 2 | 3 | This section lists all API that can be used view reports. 4 | 5 | ## Reports Filters ## 6 | 7 | Use the following filters for any type of report to specify the period of sales: 8 | 9 | | Filter | Type | Description | 10 | | ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 11 | | `period` | string | The supported periods are: `week`, `month`, `last_month`, and `year`. If you use an invalid period, `week` is used. If you don't specify a period, the current day is used | 12 | | `date_min` | string | Return sales for a specific start date. The date need to be in the `YYYY-MM-DD` format | 13 | | `date_max` | string | Return sales for a specific end date. The dates need to be in the `YYYY-MM-DD` format. Required to set the `filter[date_min]` too | 14 | 15 | ## View List Of Reports ## 16 | 17 | This API lets you retrieve and view a simple list of available reports. 18 | 19 | ### HTTP Request ### 20 | 21 |
22 |
23 | GET 24 |
/wc-api/v2/reports
25 |
26 |
27 | 28 | ```shell 29 | curl https://example.com/wc-api/v2/reports \ 30 | -u consumer_key:consumer_secret 31 | ``` 32 | 33 | ```javascript 34 | WooCommerce.get('reports', function(err, data, res) { 35 | console.log(res); 36 | }); 37 | ``` 38 | 39 | ```python 40 | print(wcapi.get("reports").json()) 41 | ``` 42 | 43 | ```php 44 | reports->get()); ?> 45 | ``` 46 | 47 | ```ruby 48 | woocommerce.get("reports").parsed_response 49 | ``` 50 | 51 | > JSON response example: 52 | 53 | ```json 54 | { 55 | "reports": [ 56 | "sales", 57 | "sales/top_sellers" 58 | ] 59 | } 60 | ``` 61 | 62 | ## View List Of Sales Report ## 63 | 64 | This API lets you retrieve and view a list of sales report. 65 | 66 | ### HTTP Request ### 67 | 68 |
69 |
70 | GET 71 |
/wc-api/v2/reports/sales
72 |
73 |
74 | 75 | ```shell 76 | curl https://example.com/wc-api/v2/reports/sales?filter[date_min]=2015-01-18&filter[date_max]=2015-01-21 \ 77 | -u consumer_key:consumer_secret 78 | ``` 79 | 80 | ```javascript 81 | WooCommerce.get('reports/sales?filter[date_min]=2015-01-18&filter[date_max]=2015-01-21', function(err, data, res) { 82 | console.log(res); 83 | }); 84 | ``` 85 | 86 | ```python 87 | print(wcapi.get("reports/sales?filter[date_min]=2015-01-18&filter[date_max]=2015-01-21").json()) 88 | ``` 89 | 90 | ```php 91 | array( 94 | 'date_min' => '2015-01-18', 95 | 'date_max' => '2015-01-21' 96 | ) 97 | ); 98 | 99 | print_r($woocommerce->reports->get_sales($args)); 100 | ?> 101 | ``` 102 | 103 | ```ruby 104 | woocommerce.get("reports/sales?filter[date_min]=2015-01-18&filter[date_max]=2015-01-21").parsed_response 105 | ``` 106 | 107 | > JSON response example: 108 | 109 | ```json 110 | { 111 | "sales": { 112 | "total_sales": "580.10", 113 | "average_sales": "145.03", 114 | "total_orders": 4, 115 | "total_items": 31, 116 | "total_tax": "26.10", 117 | "total_shipping": "20.00", 118 | "total_discount": "0.00", 119 | "totals_grouped_by": "day", 120 | "totals": { 121 | "2015-01-18": { 122 | "sales": "-17.00", 123 | "orders": 1, 124 | "items": 1, 125 | "tax": "0.00", 126 | "shipping": "0.00", 127 | "discount": "0.00", 128 | "customers": 0 129 | }, 130 | "2015-01-19": { 131 | "sales": "0.00", 132 | "orders": 0, 133 | "items": 0, 134 | "tax": "0.00", 135 | "shipping": "0.00", 136 | "discount": "0.00", 137 | "customers": 0 138 | }, 139 | "2015-01-20": { 140 | "sales": "0.00", 141 | "orders": 0, 142 | "items": 0, 143 | "tax": "0.00", 144 | "shipping": "0.00", 145 | "discount": "0.00", 146 | "customers": 0 147 | }, 148 | "2015-01-21": { 149 | "sales": "597.10", 150 | "orders": 3, 151 | "items": 30, 152 | "tax": "26.10", 153 | "shipping": "20.00", 154 | "discount": "0.00", 155 | "customers": 0 156 | } 157 | }, 158 | "total_customers": 0 159 | } 160 | } 161 | ``` 162 | 163 | ## View List Of Top Sellers Report ## 164 | 165 | This API lets you retrieve and view a list of top sellers report. 166 | 167 | ### HTTP Request ### 168 | 169 |
170 |
171 | GET 172 |
/wc-api/v2/reports/sales/top_sellers
173 |
174 |
175 | 176 | ```shell 177 | curl https://example.com/wc-api/v2/reports/sales/top_sellers?filter[period]=last_month \ 178 | -u consumer_key:consumer_secret 179 | ``` 180 | 181 | ```javascript 182 | WooCommerce.get('reports/sales/top_sellers?filter[period]=last_month', function(err, data, res) { 183 | console.log(res); 184 | }); 185 | ``` 186 | 187 | ```python 188 | print(wcapi.get("reports/sales/top_sellers?filter[period]=last_month").json()) 189 | ``` 190 | 191 | ```php 192 | array( 195 | 'period' => 'last_month' 196 | ) 197 | ); 198 | 199 | print_r($woocommerce->reports->get_top_sellers($args)); 200 | ?> 201 | ``` 202 | 203 | ```ruby 204 | woocommerce.get("reports/sales/top_sellers?filter[period]=last_month").parsed_response 205 | ``` 206 | 207 | > JSON response example: 208 | 209 | ```json 210 | { 211 | "top_sellers": [ 212 | { 213 | "title": "Happy Ninja", 214 | "product_id": "37", 215 | "quantity": "24" 216 | }, 217 | { 218 | "title": "Flying Ninja", 219 | "product_id": "70", 220 | "quantity": "14" 221 | }, 222 | { 223 | "title": "Happy Ninja", 224 | "product_id": "53", 225 | "quantity": "6" 226 | }, 227 | { 228 | "title": "Ninja Silhouette", 229 | "product_id": "31", 230 | "quantity": "3" 231 | }, 232 | { 233 | "title": "Woo Logo", 234 | "product_id": "15", 235 | "quantity": "3" 236 | }, 237 | { 238 | "title": "Woo Album #1", 239 | "product_id": "83", 240 | "quantity": "3" 241 | }, 242 | { 243 | "title": "Woo Album #4", 244 | "product_id": "96", 245 | "quantity": "1" 246 | }, 247 | { 248 | "title": "Premium Quality", 249 | "product_id": "19", 250 | "quantity": "1" 251 | }, 252 | { 253 | "title": "Ninja Silhouette", 254 | "product_id": "56", 255 | "quantity": "1" 256 | } 257 | ] 258 | } 259 | ``` 260 | -------------------------------------------------------------------------------- /source/includes/v3/_authentication-endpoint.md: -------------------------------------------------------------------------------- 1 | # Authentication Endpoint # 2 | 3 | Starting in WooCommerce 2.4 we introduced an Authentication Endpoint, This can be used by any app to allow users to generate API keys. This makes integration with WooCommerce API simpler because the user only needs to access a URL and click "accept". After being redirected back to the app, the API keys will be sent in a POST request. 4 | 5 | The following image illustrates how it's done: 6 | 7 | ![Authentication Endpoint flow](images/woocommerce-auth-endpoint-flow.png) 8 | 9 | 12 | 13 | ## URL parameters ## 14 | 15 | | Parameter | Type | Description | 16 | | -------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 17 | | `app_name` | string | Your app name mandatory | 18 | | `scope` | string | Level of access. Available: `read`, `write` and `read_write` mandatory | 19 | | `user_id` | string | User ID in your app. For your internal reference, used when the user is redirected back to your app. NOT THE USER ID IN WOOCOMMERCE mandatory | 20 | | `return_url` | string | URL the user will be redirected to after authentication mandatory | 21 | | `callback_url` | string | URL that will receive the generated API key. Note: this URL should be over **HTTPS** mandatory | 22 | 23 | ## Creating Authentication Endpoint URL ## 24 | 25 | You must use the `/wc-auth/v1/authorize` endpoint and pass the above parameters as a query string. 26 | 27 | > Example of how to build an authentication URL: 28 | 29 | ```shell 30 | # Bash example 31 | STORE_URL='http://example.com' 32 | ENDPOINT='/wc-auth/v1/authorize' 33 | PARAMS="app_name=My App Name&scope=read_write&user_id=123&return_url=http://app.com/return-page&callback_url=https://app.com/callback-endpoint" 34 | QUERY_STRING="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$PARAMS")" 35 | QUERY_STRING=$(echo $QUERY_STRING | sed -e "s/%20/\+/g" -e "s/%3D/\=/g" -e "s/%26/\&/g") 36 | 37 | echo "$STORE_URL$ENDPOINT?$QUERY_STRING" 38 | ``` 39 | 40 | ```javascript 41 | var querystring = require('querystring'); 42 | 43 | var store_url = 'http://example.com'; 44 | var endpoint = '/wc-auth/v1/authorize'; 45 | var params = { 46 | app_name: 'My App Name', 47 | scope: 'read_write', 48 | user_id: 123, 49 | return_url: 'http://app.com/return-page', 50 | callback_url: 'https://app.com/callback-endpoint' 51 | }; 52 | var query_string = querystring.stringify(params).replace(/%20/g, '+'); 53 | 54 | console.log(store_url + endpoint + '?' + query_string); 55 | ``` 56 | 57 | ```php 58 | 'My App Name', 63 | 'scope' => 'write', 64 | 'user_id' => 123, 65 | 'return_url' => 'http://app.com', 66 | 'callback_url' => 'https://app.com' 67 | ]; 68 | $query_string = http_build_query( $params ); 69 | 70 | echo $store_url . $endpoint . '?' . $query_string; 71 | ?> 72 | ``` 73 | 74 | ```python 75 | from urllib.parse import urlencode 76 | 77 | store_url = 'http://example.com' 78 | endpoint = '/wc-auth/v1/authorize' 79 | params = { 80 | "app_name": "My App Name", 81 | "scope": "read_write", 82 | "user_id": 123, 83 | "return_url": "http://app.com/return-page", 84 | "callback_url": "https://app.com/callback-endpoint" 85 | } 86 | query_string = urlencode(params) 87 | 88 | print("%s%s?%s" % (store_url, endpoint, query_string)) 89 | ``` 90 | 91 | ```ruby 92 | require "uri" 93 | 94 | store_url = 'http://example.com' 95 | endpoint = '/wc-auth/v1/authorize' 96 | params = { 97 | app_name: "My App Name", 98 | scope: "read_write", 99 | user_id: 123, 100 | return_url: "http://app.com/return-page", 101 | callback_url: "https://app.com/callback-endpoint" 102 | } 103 | query_string = URI.encode_www_form(params) 104 | 105 | puts "#{store_url}#{endpoint}?#{query_string}" 106 | ``` 107 | 108 | > Example of JSON posted with the API Keys 109 | 110 | ``` 111 | { 112 | "key_id": 1, 113 | "user_id": 123, 114 | "consumer_key": "ck_xxxxxxxxxxxxxxxx", 115 | "consumer_secret": "cs_xxxxxxxxxxxxxxxx", 116 | "key_permissions": "read_write" 117 | } 118 | ``` 119 | 120 | Example of the screen that the user will see: 121 | 122 | ![Authentication Endpoint example](images/woocommerce-auth-endpoint-example.png) 123 | 124 | ## Notes and Tips ## 125 | 126 | - While redirecting the user using `return_url`, you are also sent `success` and `user_id` parameters as query strings. 127 | - `success` sends `0` if the user denied, or `1` if authenticated successfully. 128 | - Use `user_id` to identify the user when redirected back to the (`return_url`) and also remember to save the API Keys when your `callback_url` is posted to after auth. 129 | - The auth endpoint will send the API Keys in JSON format to the `callback_url`, so it's important to remember that some languages such as PHP will not display it inside the `$_POST` global variable, in PHP you can access it using `$HTTP_RAW_POST_DATA` (for old PHP versions) or `file_get_contents('php://input');`. 130 | - This authentication endpoint is used only to make easy integration with WooCommerce REST API. THIS NOT INTENDED TO BE USED AS A LOGIN ENDPOINT FOR CUSTOMERS! 131 | -------------------------------------------------------------------------------- /source/includes/v3/_order-notes.md: -------------------------------------------------------------------------------- 1 | # Order - Notes # 2 | 3 | This section lists all API endpoints that can be used to create, edit or otherwise manipulate order notes. 4 | 5 | ## Order Notes Properties ## 6 | 7 | | Attribute | Type | Description | 8 | | --------------- | ------- | ------------------------------------------------------------------------------------------------------------------ | 9 | | `id` | integer | Order note ID read-only | 10 | | `created_at` | string | UTC DateTime when the order note was created read-only | 11 | | `note` | string | Order note required | 12 | | `customer_note` | boolean | Shows/define if the note is only for reference or for the customer (the user will be notified). Default is `false` | 13 | 14 | ## Create a Note For an Order ## 15 | 16 | This API helps you to create a new note for an order. 17 | 18 | ### HTTP Request ### 19 | 20 |
21 |
22 | POST 23 |
/wc-api/v3/orders/<id>/notes
24 |
25 |
26 | 27 | ```shell 28 | curl -X POST https://example.com/wc-api/v3/orders/645/notes \ 29 | -u consumer_key:consumer_secret \ 30 | -H "Content-Type: application/json" \ 31 | -d '{ 32 | "order_note": { 33 | "note": "Order ok!!!" 34 | } 35 | }' 36 | ``` 37 | 38 | ```javascript 39 | var data = { 40 | order_note: { 41 | note: 'Order ok!!!' 42 | } 43 | }; 44 | 45 | WooCommerce.post('orders/645/notes', data, function(err, data, res) { 46 | console.log(res); 47 | }); 48 | ``` 49 | 50 | ```php 51 | [ 54 | 'note' => 'Order ok!!!' 55 | ] 56 | ]; 57 | 58 | print_r($woocommerce->post('orders/645/notes', $data)); 59 | ?> 60 | ``` 61 | 62 | ```python 63 | data = { 64 | "order_note": { 65 | "note": "Order ok!!!" 66 | } 67 | } 68 | 69 | print(wcapi.post("orders/645/notes", data).json()) 70 | ``` 71 | 72 | ```ruby 73 | data = { 74 | order_note: { 75 | note: "Order ok!!!" 76 | } 77 | } 78 | 79 | woocommerce.post("orders/645/notes", data).parsed_response 80 | ``` 81 | 82 | > JSON response example: 83 | 84 | ```json 85 | { 86 | "order_note": { 87 | "id": "416", 88 | "created_at": "2015-01-26T20:56:44Z", 89 | "note": "Order ok!!!", 90 | "customer_note": false 91 | } 92 | } 93 | ``` 94 | 95 | ## View an Order Note ## 96 | 97 | This API lets you retrieve and view a specific note from an order. 98 | 99 | ### HTTP Request ### 100 | 101 |
102 |
103 | GET 104 |
/wc-api/v3/orders/<id>/notes/<note_id>
105 |
106 |
107 | 108 | ```shell 109 | curl https://example.com/wc-api/v3/orders/645/notes/416 \ 110 | -u consumer_key:consumer_secret 111 | ``` 112 | 113 | ```javascript 114 | WooCommerce.get('orders/645/notes/416', function(err, data, res) { 115 | console.log(res); 116 | }); 117 | ``` 118 | 119 | ```php 120 | get('orders/645/notes/416')); ?> 121 | ``` 122 | 123 | ```python 124 | print(wcapi.get("orders/645/notes/416").json()) 125 | ``` 126 | 127 | ```ruby 128 | woocommerce.get("orders/645/notes/416").parsed_response 129 | ``` 130 | 131 | > JSON response example: 132 | 133 | ```json 134 | { 135 | "order_note": { 136 | "id": "416", 137 | "created_at": "2015-01-26T20:56:44Z", 138 | "note": "Order ok!!!", 139 | "customer_note": false 140 | } 141 | } 142 | ``` 143 | 144 | ## View List of Notes From an Order ## 145 | 146 | This API helps you to view all the notes from an order. 147 | 148 | ### HTTP Request ### 149 | 150 |
151 |
152 | GET 153 |
/wc-api/v3/orders/<id>/notes
154 |
155 |
156 | 157 | ```shell 158 | curl https://example.com/wc-api/v3/orders/645/notes \ 159 | -u consumer_key:consumer_secret 160 | ``` 161 | 162 | ```javascript 163 | WooCommerce.get('orders/645/notes', function(err, data, res) { 164 | console.log(res); 165 | }); 166 | ``` 167 | 168 | ```php 169 | get('orders/645/notes')); ?> 170 | ``` 171 | 172 | ```python 173 | print(wcapi.get("orders/645/notes").json()) 174 | ``` 175 | 176 | ```ruby 177 | woocommerce.get("orders/645/notes").parsed_response 178 | ``` 179 | 180 | > JSON response example: 181 | 182 | ```json 183 | { 184 | "order_notes": [ 185 | { 186 | "id": "416", 187 | "created_at": "2015-01-26T20:56:44Z", 188 | "note": "Order ok!!!", 189 | "customer_note": false 190 | }, 191 | { 192 | "id": "415", 193 | "created_at": "2015-01-26T20:16:14Z", 194 | "note": "Order status changed from Processing to Completed.", 195 | "customer_note": false 196 | }, 197 | { 198 | "id": "412", 199 | "created_at": "2015-01-26T20:00:21Z", 200 | "note": "Order item stock reduced successfully.", 201 | "customer_note": false 202 | }, 203 | { 204 | "id": "411", 205 | "created_at": "2015-01-26T20:00:09Z", 206 | "note": "Order status changed from Pending Payment to Processing.", 207 | "customer_note": false 208 | } 209 | ] 210 | } 211 | ``` 212 | 213 | ## Update an Order Note ## 214 | 215 | This API lets you make changes to an order note. 216 | 217 | ### HTTP Request ### 218 | 219 |
220 |
221 | PUT 222 |
/wc-api/v3/orders/<id>/notes/<note_id>
223 |
224 |
225 | 226 | ```shell 227 | curl -X PUT https://example.com/wc-api/v3/orders/645/notes/416 \ 228 | -u consumer_key:consumer_secret \ 229 | -H "Content-Type: application/json" \ 230 | -d '{ 231 | "order_note": { 232 | "note": "Ok!" 233 | } 234 | }' 235 | ``` 236 | 237 | ```javascript 238 | var data = { 239 | order_note: { 240 | note: 'Ok!' 241 | } 242 | }; 243 | 244 | WooCommerce.put('orders/645/notes/416', data, function(err, data, res) { 245 | console.log(res); 246 | }); 247 | ``` 248 | 249 | ```php 250 | [ 253 | 'note' => 'Ok!' 254 | ] 255 | ]; 256 | 257 | print_r($woocommerce->put('orders/645/notes/416', $data)); 258 | ?> 259 | ``` 260 | 261 | ```python 262 | data = { 263 | "order_note": { 264 | "note": "Ok!" 265 | } 266 | } 267 | 268 | print(wcapi.put("orders/645/notes/416", data).json()) 269 | ``` 270 | 271 | ```ruby 272 | data = { 273 | order_note: { 274 | note: "Ok!" 275 | } 276 | } 277 | 278 | woocommerce.put("orders/645/notes/416", data).parsed_response 279 | ``` 280 | 281 | > JSON response example: 282 | 283 | ```json 284 | { 285 | "order_note": { 286 | "id": "416", 287 | "created_at": "2015-01-26T20:56:44Z", 288 | "note": "Ok!", 289 | "customer_note": false 290 | } 291 | } 292 | ``` 293 | 294 | ## Delete an Order Note ## 295 | 296 | This API helps you delete an order note. 297 | 298 | ### HTTP Request ### 299 | 300 |
301 |
302 | DELETE 303 |
/wc-api/v3/orders/<id>/notes/<note_id>
304 |
305 |
306 | 307 | ```shell 308 | curl -X DELETE https://example.com/wc-api/v3/orders/645/notes/416 \ 309 | -u consumer_key:consumer_secret 310 | ``` 311 | 312 | ```javascript 313 | WooCommerce.delete('orders/645/notes/416', function(err, data, res) { 314 | console.log(res); 315 | }); 316 | ``` 317 | 318 | ```php 319 | delete('orders/645/notes/416')); ?> 320 | ``` 321 | 322 | ```python 323 | print(wcapi.delete("orders/645/notes/416").json()) 324 | ``` 325 | 326 | ```ruby 327 | woocommerce.delete("orders/645/notes/416").parsed_response 328 | ``` 329 | 330 | > JSON response example: 331 | 332 | ```json 333 | { 334 | "message": "Permanently deleted order note" 335 | } 336 | ``` 337 | -------------------------------------------------------------------------------- /source/includes/v3/_order-refunds.md: -------------------------------------------------------------------------------- 1 | # Order - Refunds # 2 | 3 | This section lists all API endpoints that can be used to create, edit or otherwise manipulate order refunds. 4 | 5 | ## Order Refunds Properties ## 6 | 7 | | Attribute | Type | Description | 8 | |--------------|---------|------------------------------------------------------------------------------------------| 9 | | `id` | integer | Order note ID read-only | 10 | | `created_at` | string | UTC DateTime when the order refund was created read-only | 11 | | `amount` | string | Refund amount required | 12 | | `reason` | string | Reason for refund | 13 | | `line_items` | array | List of order items to refund. See [Line Items Properties](#line-items-properties) | 14 | 15 | ## Create a Refund For an Order ## 16 | 17 | This API helps you to create a new refund for an order. 18 | 19 | ### HTTP Request ### 20 | 21 |
22 |
23 | POST 24 |
/wc-api/v3/orders/<id>/refunds
25 |
26 |
27 | 28 | ```shell 29 | curl -X POST https://example.com/wc-api/v3/orders/645/refunds \ 30 | -u consumer_key:consumer_secret \ 31 | -H "Content-Type: application/json" \ 32 | -d '{ 33 | "order_refund": { 34 | "amount": 10 35 | } 36 | }' 37 | ``` 38 | 39 | ```javascript 40 | var data = { 41 | order_refund: { 42 | amount: 10 43 | } 44 | }; 45 | 46 | WooCommerce.post('orders/645/refunds', data, function(err, data, res) { 47 | console.log(res); 48 | }); 49 | ``` 50 | 51 | ```php 52 | [ 55 | 'amount' => 10 56 | ] 57 | ]; 58 | 59 | print_r($woocommerce->post('orders/645/refunds', $data)); 60 | ?> 61 | ``` 62 | 63 | ```python 64 | data = { 65 | "order_refund": { 66 | "amount": 10 67 | } 68 | } 69 | 70 | print(wcapi.post("orders/645/refunds", data).json()) 71 | ``` 72 | 73 | ```ruby 74 | data = { 75 | order_refund: { 76 | amount: 10 77 | } 78 | } 79 | 80 | woocommerce.post("orders/645/refunds", data).parsed_response 81 | ``` 82 | 83 | > JSON response example: 84 | 85 | ```json 86 | { 87 | "order_refund": { 88 | "id": 649, 89 | "created_at": "2015-01-26T19:29:32Z", 90 | "amount": "10.00", 91 | "reason": "", 92 | "line_items": [] 93 | } 94 | } 95 | ``` 96 | 97 | ## View an Order Refund ## 98 | 99 | This API lets you retrieve and view a specific refund from an order. 100 | 101 | ### HTTP Request ### 102 | 103 |
104 |
105 | GET 106 |
/wc-api/v3/orders/<id>/refunds/<refund_id>
107 |
108 |
109 | 110 | ```shell 111 | curl https://example.com/wc-api/v3/orders/645/refunds/649 \ 112 | -u consumer_key:consumer_secret 113 | ``` 114 | 115 | ```javascript 116 | WooCommerce.get('orders/645/refunds/649', function(err, data, res) { 117 | console.log(res); 118 | }); 119 | ``` 120 | 121 | ```php 122 | get('orders/645/refunds/649')); ?> 123 | ``` 124 | 125 | ```python 126 | print(wcapi.get("orders/645/refunds/649").json()) 127 | ``` 128 | 129 | ```ruby 130 | woocommerce.get("orders/645/refunds/649").parsed_response 131 | ``` 132 | 133 | > JSON response example: 134 | 135 | ```json 136 | { 137 | "order_refund": { 138 | "id": 649, 139 | "created_at": "2015-01-26T19:29:32Z", 140 | "amount": "10.00", 141 | "reason": "", 142 | "line_items": [] 143 | } 144 | } 145 | ``` 146 | 147 | ## View List of Refunds From an Order ## 148 | 149 | This API helps you to view all the refunds from an order. 150 | 151 | ### HTTP Request ### 152 | 153 |
154 |
155 | GET 156 |
/wc-api/v3/orders/<id>/refunds
157 |
158 |
159 | 160 | ```shell 161 | curl https://example.com/wc-api/v3/orders/645/refunds \ 162 | -u consumer_key:consumer_secret 163 | ``` 164 | 165 | ```javascript 166 | WooCommerce.get('orders/645/refunds', function(err, data, res) { 167 | console.log(res); 168 | }); 169 | ``` 170 | 171 | ```php 172 | get('orders/645/refunds')); ?> 173 | ``` 174 | 175 | ```python 176 | print(wcapi.get("orders/645/refunds").json()) 177 | ``` 178 | 179 | ```ruby 180 | woocommerce.get("orders/645/refunds").parsed_response 181 | ``` 182 | 183 | > JSON response example: 184 | 185 | ```json 186 | { 187 | "order_refunds": [ 188 | { 189 | "id": 649, 190 | "created_at": "2015-01-26T19:29:32Z", 191 | "amount": "10.00", 192 | "reason": "", 193 | "line_items": [] 194 | }, 195 | { 196 | "id": 647, 197 | "created_at": "2015-01-26T19:19:06Z", 198 | "amount": "21.99", 199 | "reason": "", 200 | "line_items": [ 201 | { 202 | "id": 514, 203 | "subtotal": "-21.99", 204 | "subtotal_tax": "0.00", 205 | "total": "-21.99", 206 | "total_tax": "0.00", 207 | "price": "-21.99", 208 | "quantity": 1, 209 | "tax_class": "reduced-rate", 210 | "name": "Premium Quality", 211 | "product_id": 546, 212 | "sku": "", 213 | "meta": [] 214 | }, 215 | { 216 | "id": 515, 217 | "subtotal": "0.00", 218 | "subtotal_tax": "0.00", 219 | "total": "0.00", 220 | "total_tax": "0.00", 221 | "price": "0.00", 222 | "quantity": 0, 223 | "tax_class": null, 224 | "name": "Ship Your Idea", 225 | "product_id": 613, 226 | "sku": "", 227 | "meta": [] 228 | } 229 | ] 230 | } 231 | ] 232 | } 233 | ``` 234 | 235 | ## Update an Order Refund ## 236 | 237 | This API lets you make changes to an order refund. 238 | 239 | ### HTTP Request ### 240 | 241 |
242 |
243 | PUT 244 |
/wc-api/v3/orders/<id>/refunds/<refund_id>
245 |
246 |
247 | 248 | ```shell 249 | curl -X PUT https://example.com/wc-api/v3/orders/645/refunds/649 \ 250 | -u consumer_key:consumer_secret \ 251 | -H "Content-Type: application/json" \ 252 | -d '{ 253 | "order_refund": { 254 | "reason": "Because was it necessary!" 255 | } 256 | }' 257 | ``` 258 | 259 | ```javascript 260 | var data = { 261 | order_refund: { 262 | reason: 'Because was it necessary!' 263 | } 264 | }; 265 | 266 | WooCommerce.put('orders/645/refunds/649', data, function(err, data, res) { 267 | console.log(res); 268 | }); 269 | ``` 270 | 271 | ```php 272 | [ 275 | 'reason' => 'Because was it necessary!' 276 | ] 277 | ]; 278 | 279 | print_r($woocommerce->put('orders/645/refunds/649', $data)); 280 | ?> 281 | ``` 282 | 283 | ```python 284 | data = { 285 | "order_refund": { 286 | "reason": "Because was it necessary!" 287 | } 288 | } 289 | 290 | print(wcapi.put("orders/645/refunds/649", data).json()) 291 | ``` 292 | 293 | ```ruby 294 | data = { 295 | order_refund: { 296 | reason: "Because was it necessary!" 297 | } 298 | } 299 | 300 | woocommerce.put("orders/645/refunds/649", data).parsed_response 301 | ``` 302 | 303 | > JSON response example: 304 | 305 | ```json 306 | { 307 | "order_refund": { 308 | "id": 649, 309 | "created_at": "2015-01-26T19:29:32Z", 310 | "amount": "10.00", 311 | "reason": "Because was it necessary!", 312 | "line_items": [] 313 | } 314 | } 315 | ``` 316 | 317 | ## Delete an Order Refund ## 318 | 319 | This API helps you delete an order refund. 320 | 321 | ### HTTP Request ### 322 | 323 |
324 |
325 | DELETE 326 |
/wc-api/v3/orders/<id>/refunds/<refund_id>
327 |
328 |
329 | 330 | ```shell 331 | curl -X DELETE https://example.com/wc-api/v3/orders/645/refunds/649 \ 332 | -u consumer_key:consumer_secret 333 | ``` 334 | 335 | ```javascript 336 | WooCommerce.delete('orders/645/refunds/649', function(err, data, res) { 337 | console.log(res); 338 | }); 339 | ``` 340 | 341 | ```php 342 | delete('orders/645/refunds/649')); ?> 343 | ``` 344 | 345 | ```python 346 | print(wcapi.delete("orders/645/refunds/649").json()) 347 | ``` 348 | 349 | ```ruby 350 | woocommerce.delete("orders/645/refunds/649").parsed_response 351 | ``` 352 | 353 | > JSON response example: 354 | 355 | ```json 356 | { 357 | "message": "Permanently deleted refund" 358 | } 359 | ``` 360 | -------------------------------------------------------------------------------- /source/includes/v3/_product-attribute-terms.md: -------------------------------------------------------------------------------- 1 | # Product - Attribute Terms # 2 | 3 | This section lists all API endpoints that can be used to create, edit or otherwise manipulate product attribute terms. 4 | 5 | ## Product Attribute Properties ## 6 | 7 | | Attribute | Type | Description | 8 | | --------- | ------- | ------------------------------------------------------------------------------------- | 9 | | `id` | integer | Term ID (term ID) read-only | 10 | | `name` | string | Term name required | 11 | | `slug` | string | Term slug | 12 | | `count` | integer | Shows the quantity of products in this term read-only | 13 | 14 | ## Create a Product Attribute Term ## 15 | 16 | This API helps you to create a new product attribute term. 17 | 18 | ### HTTP Request ### 19 | 20 |
21 |
22 | POST 23 |
/wc-api/v3/products/attributes/<attribute_id>/terms
24 |
25 |
26 | 27 | ```shell 28 | curl -X POST https://example.com/wc-api/v3/products/attributes/1/terms \ 29 | -u consumer_key:consumer_secret \ 30 | -H "Content-Type: application/json" \ 31 | -d '{ 32 | "product_attribute_term": { 33 | "name": "Black" 34 | } 35 | }' 36 | ``` 37 | 38 | ```javascript 39 | var data = { 40 | product_attribute_term: { 41 | name: 'Black' 42 | } 43 | }; 44 | 45 | WooCommerce.post('products/attributes/1/terms', data, function(err, data, res) { 46 | console.log(res); 47 | }); 48 | ``` 49 | 50 | ```php 51 | [ 54 | 'name' => 'Black' 55 | ] 56 | ]; 57 | 58 | print_r($woocommerce->post('products/attributes/1/terms', $data)); 59 | ?> 60 | ``` 61 | 62 | ```python 63 | data = { 64 | "product_attribute_term": { 65 | "name": "Black" 66 | } 67 | } 68 | 69 | print(wcapi.post("products/attributes/1/terms", data).json()) 70 | ``` 71 | 72 | ```ruby 73 | data = { 74 | product_attribute_term: { 75 | name: "Black" 76 | } 77 | } 78 | 79 | woocommerce.post("products/attributes/1/terms", data).parsed_response 80 | ``` 81 | 82 | > JSON response example: 83 | 84 | ```json 85 | { 86 | "product_attribute_term": { 87 | "id": 18, 88 | "name": "Black", 89 | "slug": "black", 90 | "count": 0 91 | } 92 | } 93 | ``` 94 | 95 | 98 | 99 | ## View a Product Attribute Term ## 100 | 101 | This API lets you retrieve a product attribute term by ID. 102 | 103 |
104 |
105 | GET 106 |
/wc-api/v3/products/attributes/<attribute_id>/terms/<id>
107 |
108 |
109 | 110 | ```shell 111 | curl https://example.com/wc-api/v3/products/attributes/1/terms/18 \ 112 | -u consumer_key:consumer_secret 113 | ``` 114 | 115 | ```javascript 116 | WooCommerce.get('products/attributes/1/terms/18', function(err, data, res) { 117 | console.log(res); 118 | }); 119 | ``` 120 | 121 | ```php 122 | get('products/attributes/1/terms/18')); ?> 123 | ``` 124 | 125 | ```python 126 | print(wcapi.get("products/attributes/1/terms/18").json()) 127 | ``` 128 | 129 | ```ruby 130 | woocommerce.get("products/attributes/1/terms/18").parsed_response 131 | ``` 132 | 133 | > JSON response example: 134 | 135 | ```json 136 | { 137 | "product_attribute_term": { 138 | "id": 18, 139 | "name": "Black", 140 | "slug": "black", 141 | "count": 5 142 | } 143 | } 144 | ``` 145 | 146 | 149 | 150 | ## View List of Product Attribute Terms ## 151 | 152 | This API lets you retrieve all terms from a product attribute. 153 | 154 |
155 |
156 | GET 157 |
/wc-api/v3/products/attributes/<attribute_id>/terms
158 |
159 |
160 | 161 | ```shell 162 | curl https://example.com/wc-api/v3/products/attributes/1/terms \ 163 | -u consumer_key:consumer_secret 164 | ``` 165 | 166 | ```javascript 167 | WooCommerce.get('products/attributes/1/terms', function(err, data, res) { 168 | console.log(res); 169 | }); 170 | ``` 171 | 172 | ```php 173 | get('products/attributes/1/terms')); ?> 174 | ``` 175 | 176 | ```python 177 | print(wcapi.get("products/attributes/1/terms").json()) 178 | ``` 179 | 180 | ```ruby 181 | woocommerce.get("products/attributes/1/terms").parsed_response 182 | ``` 183 | 184 | > JSON response example: 185 | 186 | ```json 187 | { 188 | "product_attribute_terms": [ 189 | { 190 | "id": 18, 191 | "slug": "black", 192 | "name": "Black", 193 | "count": 5 194 | }, 195 | { 196 | "id": 20, 197 | "slug": "blue", 198 | "name": "Blue", 199 | "count": 4 200 | }, 201 | { 202 | "id": 19, 203 | "slug": "green", 204 | "name": "Green", 205 | "count": 4 206 | }, 207 | { 208 | "id": 24, 209 | "slug": "pink", 210 | "name": "Pink", 211 | "count": 3 212 | }, 213 | { 214 | "id": 22, 215 | "slug": "red", 216 | "name": "Red", 217 | "count": 3 218 | }, 219 | { 220 | "id": 21, 221 | "slug": "white", 222 | "name": "White", 223 | "count": 3 224 | }, 225 | { 226 | "id": 23, 227 | "slug": "yellow", 228 | "name": "Yellow", 229 | "count": 3 230 | } 231 | ] 232 | } 233 | ``` 234 | 235 | 238 | 239 | ## Update a Product Attribute Term ## 240 | 241 | This API lets you make changes to a product attribute term. 242 | 243 | ### HTTP Request ### 244 | 245 |
246 |
247 | PUT 248 |
/wc-api/v3/products/attributes/<attribute_id>/terms/<id>
249 |
250 |
251 | 252 | ```shell 253 | curl -X PUT https://example.com/wc-api/v3/products/attributes/1/terms/18 \ 254 | -u consumer_key:consumer_secret \ 255 | -H "Content-Type: application/json" \ 256 | -d '{ 257 | "product_attribute_term": { 258 | "name": "BLACK" 259 | } 260 | }' 261 | ``` 262 | 263 | ```javascript 264 | var data = { 265 | product_attribute_term: { 266 | name: 'BLACK' 267 | } 268 | }; 269 | 270 | WooCommerce.put('products/attributes/1/terms/18', data, function(err, data, res) { 271 | console.log(res); 272 | }); 273 | ``` 274 | 275 | ```php 276 | [ 279 | 'name' => 'BLACK' 280 | ] 281 | ]; 282 | 283 | print_r($woocommerce->put('products/attributes/1/terms/18', $data)); 284 | ?> 285 | ``` 286 | 287 | ```python 288 | data = { 289 | "product_attribute_term": { 290 | "name": "BLACK" 291 | } 292 | } 293 | 294 | print(wcapi.put("products/attributes/1/terms/18", data).json()) 295 | ``` 296 | 297 | ```ruby 298 | data = { 299 | product_attribute_term: { 300 | name: "BLACK" 301 | } 302 | } 303 | 304 | woocommerce.put("products/attributes/1/terms/18", data).parsed_response 305 | ``` 306 | 307 | > JSON response example: 308 | 309 | ```json 310 | { 311 | "product_attribute_term": { 312 | "id": 18, 313 | "name": "BLACK", 314 | "slug": "black", 315 | "count": 5 316 | } 317 | } 318 | ``` 319 | 320 | 323 | 324 | ## Delete a Product Attribute Term ## 325 | 326 | This API helps you delete a product attribute term. 327 | 328 | ### HTTP Request ### 329 | 330 |
331 |
332 | DELETE 333 |
/wc-api/v3/products/attributes/<attribute_id>/terms/<id>
334 |
335 |
336 | 337 | ```shell 338 | curl -X DELETE https://example.com/wc-api/v3/products/attributes/1/terms/18 \ 339 | -u consumer_key:consumer_secret 340 | ``` 341 | 342 | ```javascript 343 | WooCommerce.delete('products/attributes/1/terms/18', function(err, data, res) { 344 | console.log(res); 345 | }); 346 | ``` 347 | 348 | ```php 349 | delete('products/attributes/1/terms/18')); ?> 350 | ``` 351 | 352 | ```python 353 | print(wcapi.delete("products/attributes/1/terms/18").json()) 354 | ``` 355 | 356 | ```ruby 357 | woocommerce.delete("products/attributes/1/terms/18").parsed_response 358 | ``` 359 | 360 | > JSON response example: 361 | 362 | ```json 363 | { 364 | "message": "Deleted product_attribute_term" 365 | } 366 | ``` 367 | 368 | 371 | -------------------------------------------------------------------------------- /source/includes/v3/_product-attributes.md: -------------------------------------------------------------------------------- 1 | # Product - Attributes # 2 | 3 | This section lists all API endpoints that can be used to create, edit or otherwise manipulate product attributes. 4 | 5 | ## Product Attribute Properties ## 6 | 7 | | Attribute | Type | Description | 8 | | -------------- | ------- | -------------------------------------------------------------------------------------------------------------------- | 9 | | `id` | integer | Attribute ID read-only | 10 | | `name` | string | Attribute name | 11 | | `slug` | string | Attribute slug | 12 | | `type` | string | Attribute type, the types available include by default are: `select` and `text` (some plugins can include new types) | 13 | | `order_by` | string | Default sort order. Available: `menu_order`, `name`, `name_num` and `id` | 14 | | `has_archives` | boolean | Enable/Disable attribute archives | 15 | 16 | ## Create a Product Attribute ## 17 | 18 | This API helps you to create a new product attribute. 19 | 20 | ### HTTP Request ### 21 | 22 |
23 |
24 | POST 25 |
/wc-api/v3/products/attributes
26 |
27 |
28 | 29 | ```shell 30 | curl -X POST https://example.com/wc-api/v3/products/attributes \ 31 | -u consumer_key:consumer_secret \ 32 | -H "Content-Type: application/json" \ 33 | -d '{ 34 | "product_attribute": { 35 | "name": "Color", 36 | "slug": "pa_color", 37 | "type": "select", 38 | "order_by": "menu_order", 39 | "has_archives": true 40 | } 41 | }' 42 | ``` 43 | 44 | ```javascript 45 | var data = { 46 | product_attribute: { 47 | name: 'Color', 48 | slug: 'pa_color', 49 | type: 'select', 50 | order_by: 'menu_order', 51 | has_archives: true 52 | } 53 | }; 54 | 55 | WooCommerce.post('products/attributes', data, function(err, data, res) { 56 | console.log(res); 57 | }); 58 | ``` 59 | 60 | ```php 61 | [ 64 | 'name' => 'Color', 65 | 'slug' => 'pa_color', 66 | 'type' => 'select', 67 | 'order_by' => 'menu_order', 68 | 'has_archives' => true 69 | ] 70 | ]; 71 | 72 | print_r($woocommerce->post('products/attributes', $data)); 73 | ?> 74 | ``` 75 | 76 | ```python 77 | data = { 78 | "product_attribute": { 79 | "name": "Color", 80 | "slug": "pa_color", 81 | "type": "select", 82 | "order_by": "menu_order", 83 | "has_archives": True 84 | } 85 | } 86 | 87 | print(wcapi.post("products/attributes", data).json()) 88 | ``` 89 | 90 | ```ruby 91 | data = { 92 | product_attribute: { 93 | name: "Color", 94 | slug: "pa_color", 95 | type: "select", 96 | order_by: "menu_order", 97 | has_archives: true 98 | } 99 | } 100 | 101 | woocommerce.post("products/attributes", data).parsed_response 102 | ``` 103 | 104 | > JSON response example: 105 | 106 | ```json 107 | { 108 | "product_attribute": { 109 | "id": 1, 110 | "name": "Color", 111 | "slug": "pa_color", 112 | "type": "select", 113 | "order_by": "menu_order", 114 | "has_archives": true 115 | } 116 | } 117 | ``` 118 | 119 | ## View a Product Attribute ## 120 | 121 | This API lets you retrieve and view a specific product attribute by ID. 122 | 123 |
124 |
125 | GET 126 |
/wc-api/v3/products/attributes/<id>
127 |
128 |
129 | 130 | ```shell 131 | curl https://example.com/wc-api/v3/products/attributes/1 \ 132 | -u consumer_key:consumer_secret 133 | ``` 134 | 135 | ```javascript 136 | WooCommerce.get('products/attributes/1', function(err, data, res) { 137 | console.log(res); 138 | }); 139 | ``` 140 | 141 | ```php 142 | get('products/attributes/1')); ?> 143 | ``` 144 | 145 | ```python 146 | print(wcapi.get("products/attributes/1").json()) 147 | ``` 148 | 149 | ```ruby 150 | woocommerce.get("products/attributes/1").parsed_response 151 | ``` 152 | 153 | > JSON response example: 154 | 155 | ```json 156 | { 157 | "product_attribute": { 158 | "id": 1, 159 | "name": "Color", 160 | "slug": "pa_color", 161 | "type": "select", 162 | "order_by": "menu_order", 163 | "has_archives": true 164 | } 165 | } 166 | ``` 167 | 168 | ## View List of Product Attributes ## 169 | 170 | This API helps you to view all the product attributes. 171 | 172 | ### HTTP Request ### 173 | 174 |
175 |
176 | GET 177 |
/wc-api/v3/products/attributes
178 |
179 |
180 | 181 | ```shell 182 | curl https://example.com/wc-api/v3/products/attributes \ 183 | -u consumer_key:consumer_secret 184 | ``` 185 | 186 | ```javascript 187 | WooCommerce.get('products/attributes', function(err, data, res) { 188 | console.log(res); 189 | }); 190 | ``` 191 | 192 | ```php 193 | get('products/attributes')); ?> 194 | ``` 195 | 196 | ```python 197 | print(wcapi.get("products/attributes").json()) 198 | ``` 199 | 200 | ```ruby 201 | woocommerce.get("products/attributes").parsed_response 202 | ``` 203 | 204 | > JSON response example: 205 | 206 | ```json 207 | { 208 | "product_attributes": [ 209 | { 210 | "id": 1, 211 | "name": "Color", 212 | "slug": "pa_color", 213 | "type": "select", 214 | "order_by": "menu_order", 215 | "has_archives": true 216 | }, 217 | { 218 | "id": 2, 219 | "name": "Size", 220 | "slug": "pa_size", 221 | "type": "select", 222 | "order_by": "menu_order", 223 | "has_archives": false 224 | } 225 | ] 226 | } 227 | ``` 228 | 229 | ## Update a Product Attribute ## 230 | 231 | This API lets you make changes to a product attribute. 232 | 233 | ### HTTP Request ### 234 | 235 |
236 |
237 | PUT 238 |
/wc-api/v3/products/attributes/<id>
239 |
240 |
241 | 242 | ```shell 243 | curl -X PUT https://example.com/wc-api/v3/products/attributes/1 \ 244 | -u consumer_key:consumer_secret \ 245 | -H "Content-Type: application/json" \ 246 | -d '{ 247 | "product_attribute": { 248 | "order_by": "name" 249 | } 250 | }' 251 | ``` 252 | 253 | ```javascript 254 | var data = { 255 | product_attribute: { 256 | order_by: 'name' 257 | } 258 | }; 259 | 260 | WooCommerce.put('products/attributes/1', data, function(err, data, res) { 261 | console.log(res); 262 | }); 263 | ``` 264 | 265 | ```php 266 | [ 269 | 'order_by' => 'name' 270 | ] 271 | ]; 272 | 273 | print_r($woocommerce->put('products/attributes/1', $data)); 274 | ?> 275 | ``` 276 | 277 | ```python 278 | data = { 279 | "product_attribute": { 280 | "order_by": "name" 281 | } 282 | } 283 | 284 | print(wcapi.put("products/attributes/1", data).json()) 285 | ``` 286 | 287 | ```ruby 288 | data = { 289 | product_attribute: { 290 | order_by: "name" 291 | } 292 | } 293 | 294 | woocommerce.put("products/attributes/1", data).parsed_response 295 | ``` 296 | 297 | > JSON response example: 298 | 299 | ```json 300 | { 301 | "product_attribute": { 302 | "id": 1, 303 | "name": "Color", 304 | "slug": "pa_color", 305 | "type": "select", 306 | "order_by": "name", 307 | "has_archives": true 308 | } 309 | } 310 | ``` 311 | 312 | ## Delete a Product Attribute ## 313 | 314 | This API helps you delete a product attribute. 315 | 316 | ### HTTP Request ### 317 | 318 |
319 |
320 | DELETE 321 |
/wc-api/v3/products/attributes/<id>
322 |
323 |
324 | 325 | ```shell 326 | curl -X DELETE https://example.com/wc-api/v3/products/attributes/1 \ 327 | -u consumer_key:consumer_secret 328 | ``` 329 | 330 | ```javascript 331 | WooCommerce.delete('products/attributes/1', function(err, data, res) { 332 | console.log(res); 333 | }); 334 | ``` 335 | 336 | ```php 337 | delete('products/attributes/1')); ?> 338 | ``` 339 | 340 | ```python 341 | print(wcapi.delete("products/attributes/1").json()) 342 | ``` 343 | 344 | ```ruby 345 | woocommerce.delete("products/attributes/1").parsed_response 346 | ``` 347 | 348 | > JSON response example: 349 | 350 | ```json 351 | { 352 | "message": "Deleted product_attribute" 353 | } 354 | ``` 355 | -------------------------------------------------------------------------------- /source/includes/v3/_product-shipping-classes.md: -------------------------------------------------------------------------------- 1 | # Product - Shipping Classes # 2 | 3 | This section lists all API endpoints that can be used to create, edit or otherwise manipulate product shipping classes. 4 | 5 | ## Product Shipping Class Properties ## 6 | 7 | | Attribute | Type | Description | 8 | | ------------- | ------- | ----------------------------------------------------------------------------------------------- | 9 | | `id` | integer | Shipping Class ID (term ID) read-only | 10 | | `name` | string | Shipping Class name required | 11 | | `slug` | string | Shipping Class slug | 12 | | `parent` | integer | Shipping Class parent | 13 | | `description` | string | Shipping Class description | 14 | | `count` | integer | Shows the quantity of products in this shipping class read-only | 15 | 16 | ## Create a Product Shipping Class ## 17 | 18 | This API helps you to create a new product shipping class. 19 | 20 | ### HTTP Request ### 21 | 22 |
23 |
24 | POST 25 |
/wc-api/v3/products/shipping_classes
26 |
27 |
28 | 29 | > Example of how to create a product shipping class: 30 | 31 | ```shell 32 | curl -X POST https://example.com/wc-api/v3/products/shipping_classes \ 33 | -u consumer_key:consumer_secret \ 34 | -H "Content-Type: application/json" \ 35 | -d '{ 36 | "product_shipping_class": { 37 | "name": "Priority" 38 | } 39 | }' 40 | ``` 41 | 42 | ```javascript 43 | var data = { 44 | product_shipping_class: { 45 | name: 'Priority' 46 | } 47 | }; 48 | 49 | WooCommerce.post('products/shipping_classes', data, function(err, data, res) { 50 | console.log(res); 51 | }); 52 | ``` 53 | 54 | ```php 55 | [ 58 | 'name' => 'Priority' 59 | ] 60 | ]; 61 | 62 | print_r($woocommerce->post('products/shipping_classes', $data)); 63 | ?> 64 | ``` 65 | 66 | ```python 67 | data = { 68 | "product_shipping_class": { 69 | "name": "Priority" 70 | } 71 | } 72 | 73 | print(wcapi.post("products/shipping_classes", data).json()) 74 | ``` 75 | 76 | ```ruby 77 | data = { 78 | product_shipping_class: { 79 | name: "Priority" 80 | } 81 | } 82 | 83 | woocommerce.post("products/shipping_classes", data).parsed_response 84 | ``` 85 | 86 | > JSON response example: 87 | 88 | ```json 89 | { 90 | "product_shipping_class": { 91 | "id": 35, 92 | "name": "Priority", 93 | "slug": "priority", 94 | "parent": 0, 95 | "description": "", 96 | "count": 0 97 | } 98 | } 99 | ``` 100 | 101 | 104 | 105 | ## View a Product Shipping Class ## 106 | 107 | This API lets you retrieve a product shipping class by ID. 108 | 109 |
110 |
111 | GET 112 |
/wc-api/v3/products/shipping_classes/<id>
113 |
114 |
115 | 116 | ```shell 117 | curl https://example.com/wc-api/v3/products/shipping_classes/35 \ 118 | -u consumer_key:consumer_secret 119 | ``` 120 | 121 | ```javascript 122 | WooCommerce.get('products/shipping_classes/35', function(err, data, res) { 123 | console.log(res); 124 | }); 125 | ``` 126 | 127 | ```php 128 | get('products/shipping_classes/35')); ?> 129 | ``` 130 | 131 | ```python 132 | print(wcapi.get("products/shipping_classes/35").json()) 133 | ``` 134 | 135 | ```ruby 136 | woocommerce.get("products/shipping_classes/35").parsed_response 137 | ``` 138 | 139 | > JSON response example: 140 | 141 | ```json 142 | { 143 | "product_shipping_class": { 144 | "id": 35, 145 | "name": "Priority", 146 | "slug": "priority", 147 | "parent": 0, 148 | "description": "", 149 | "count": 0 150 | } 151 | } 152 | ``` 153 | 154 | 157 | 158 | ## View List of Product Shipping Classes ## 159 | 160 | This API lets you retrieve all product shipping classes. 161 | 162 |
163 |
164 | GET 165 |
/wc-api/v3/products/shipping_classes
166 |
167 |
168 | 169 | ```shell 170 | curl https://example.com/wc-api/v3/products/shipping_classes \ 171 | -u consumer_key:consumer_secret 172 | ``` 173 | 174 | ```javascript 175 | WooCommerce.get('products/shipping_classes', function(err, data, res) { 176 | console.log(res); 177 | }); 178 | ``` 179 | 180 | ```php 181 | get('products/shipping_classes')); ?> 182 | ``` 183 | 184 | ```python 185 | print(wcapi.get("products/shipping_classes").json()) 186 | ``` 187 | 188 | ```ruby 189 | woocommerce.get("products/shipping_classes").parsed_response 190 | ``` 191 | 192 | > JSON response example: 193 | 194 | ```json 195 | { 196 | "product_shipping_classes": [ 197 | { 198 | "id": 30, 199 | "name": "Express", 200 | "slug": "express", 201 | "parent": 0, 202 | "description": "", 203 | "count": 1 204 | }, 205 | { 206 | "id": 35, 207 | "name": "Priority", 208 | "slug": "priority", 209 | "parent": 0, 210 | "description": "", 211 | "count": 0 212 | } 213 | ] 214 | } 215 | ``` 216 | 217 | 220 | 221 | ## Update a Product Shipping Class ## 222 | 223 | This API lets you make changes to a product shipping class. 224 | 225 | ### HTTP Request ### 226 | 227 |
228 |
229 | PUT 230 |
/wc-api/v3/products/shipping_classes/<id>
231 |
232 |
233 | 234 | ```shell 235 | curl -X PUT https://example.com/wc-api/v3/products/shipping_classes/35 \ 236 | -u consumer_key:consumer_secret \ 237 | -H "Content-Type: application/json" \ 238 | -d '{ 239 | "product_shipping_class": { 240 | "description": "Priority mail." 241 | } 242 | }' 243 | ``` 244 | 245 | ```javascript 246 | var data = { 247 | product_shipping_class: { 248 | description: 'Priority mail.' 249 | } 250 | }; 251 | 252 | WooCommerce.put('products/shipping_classes/35', data, function(err, data, res) { 253 | console.log(res); 254 | }); 255 | ``` 256 | 257 | ```php 258 | [ 261 | 'description' => 'Priority mail.' 262 | ] 263 | ]; 264 | 265 | print_r($woocommerce->put('products/shipping_classes/35', $data)); 266 | ?> 267 | ``` 268 | 269 | ```python 270 | data = { 271 | "product_shipping_class": { 272 | "description": "Priority mail." 273 | } 274 | } 275 | 276 | print(wcapi.put("products/shipping_classes/35", data).json()) 277 | ``` 278 | 279 | ```ruby 280 | data = { 281 | product_shipping_class: { 282 | description: "Priority mail." 283 | } 284 | } 285 | 286 | woocommerce.put("products/shipping_classes/35", data).parsed_response 287 | ``` 288 | 289 | > JSON response example: 290 | 291 | ```json 292 | { 293 | "product_shipping_class": { 294 | "id": 35, 295 | "name": "Priority", 296 | "slug": "priority", 297 | "parent": 0, 298 | "description": "Priority mail.", 299 | "count": 0 300 | } 301 | } 302 | ``` 303 | 304 | 307 | 308 | ## Delete a Product Shipping Class ## 309 | 310 | This API helps you delete a product shipping class. 311 | 312 | ### HTTP Request ### 313 | 314 |
315 |
316 | DELETE 317 |
/wc-api/v3/products/shipping_classes/<id>
318 |
319 |
320 | 321 | ```shell 322 | curl -X DELETE https://example.com/wc-api/v3/products/shipping_classes/35 \ 323 | -u consumer_key:consumer_secret 324 | ``` 325 | 326 | ```javascript 327 | WooCommerce.delete('products/shipping_classes/35', function(err, data, res) { 328 | console.log(res); 329 | }); 330 | ``` 331 | 332 | ```php 333 | delete('products/shipping_classes/35')); ?> 334 | ``` 335 | 336 | ```python 337 | print(wcapi.delete("products/shipping_classes/35").json()) 338 | ``` 339 | 340 | ```ruby 341 | woocommerce.delete("products/shipping_classes/35").parsed_response 342 | ``` 343 | 344 | > JSON response example: 345 | 346 | ```json 347 | { 348 | "message": "Deleted product_shipping_class" 349 | } 350 | ``` 351 | 352 | 355 | -------------------------------------------------------------------------------- /source/includes/v3/_product-tags.md: -------------------------------------------------------------------------------- 1 | # Product - Tags # 2 | 3 | This section lists all API endpoints that can be used to create, edit or otherwise manipulate product tags. 4 | 5 | ## Product Tag Properties ## 6 | 7 | | Attribute | Type | Description | 8 | | ------------- | ------- | ------------------------------------------------------------------------------------ | 9 | | `id` | integer | Tag ID (term ID) read-only | 10 | | `name` | string | Tag name required | 11 | | `slug` | string | Tag slug | 12 | | `description` | string | Tag description | 13 | | `count` | integer | Shows the quantity of products in this tag read-only | 14 | 15 | ## Create a Product Tag ## 16 | 17 | This API helps you to create a new product tag. 18 | 19 | ### HTTP Request ### 20 | 21 |
22 |
23 | POST 24 |
/wc-api/v3/products/tags
25 |
26 |
27 | 28 | > Example of how to create a product tag: 29 | 30 | ```shell 31 | curl -X POST https://example.com/wc-api/v3/products/tags \ 32 | -u consumer_key:consumer_secret \ 33 | -H "Content-Type: application/json" \ 34 | -d '{ 35 | "product_tag": { 36 | "name": "Leather Shoes" 37 | } 38 | }' 39 | ``` 40 | 41 | ```javascript 42 | var data = { 43 | product_tag: { 44 | name: 'Leather Shoes' 45 | } 46 | }; 47 | 48 | WooCommerce.post('products/tags', data, function(err, data, res) { 49 | console.log(res); 50 | }); 51 | ``` 52 | 53 | ```php 54 | 'Leather Shoes' 58 | ] 59 | ]; 60 | 61 | print_r($woocommerce->post('products/tags', $data)); 62 | ?> 63 | ``` 64 | 65 | ```python 66 | data = { 67 | "product_tag": { 68 | "name": "Leather Shoes" 69 | } 70 | } 71 | 72 | print(wcapi.post("products/tags", data).json()) 73 | ``` 74 | 75 | ```ruby 76 | data = { 77 | product_tag: { 78 | name: "Leather Shoes" 79 | } 80 | } 81 | 82 | woocommerce.post("products/tags", data).parsed_response 83 | ``` 84 | 85 | > JSON response example: 86 | 87 | ```json 88 | { 89 | "product_tag": { 90 | "id": 37, 91 | "name": "Leather Shoes", 92 | "slug": "leather-shoes", 93 | "description": "", 94 | "count": 0 95 | } 96 | } 97 | ``` 98 | 99 | 102 | 103 | ## View a Product Tag ## 104 | 105 | This API lets you retrieve a product tag by ID. 106 | 107 |
108 |
109 | GET 110 |
/wc-api/v3/products/tags/<id>
111 |
112 |
113 | 114 | ```shell 115 | curl https://example.com/wc-api/v3/products/tags/37 \ 116 | -u consumer_key:consumer_secret 117 | ``` 118 | 119 | ```javascript 120 | WooCommerce.get('products/tags/37', function(err, data, res) { 121 | console.log(res); 122 | }); 123 | ``` 124 | 125 | ```php 126 | get('products/tags/37')); ?> 127 | ``` 128 | 129 | ```python 130 | print(wcapi.get("products/tags/37").json()) 131 | ``` 132 | 133 | ```ruby 134 | woocommerce.get("products/tags/37").parsed_response 135 | ``` 136 | 137 | > JSON response example: 138 | 139 | ```json 140 | { 141 | "product_tag": { 142 | "id": 37, 143 | "name": "Leather Shoes", 144 | "slug": "leather-shoes", 145 | "description": "", 146 | "count": 0 147 | } 148 | } 149 | ``` 150 | 151 | 154 | 155 | ## View List of Product Tags ## 156 | 157 | This API lets you retrieve all product tag. 158 | 159 |
160 |
161 | GET 162 |
/wc-api/v3/products/tags
163 |
164 |
165 | 166 | ```shell 167 | curl https://example.com/wc-api/v3/products/tags \ 168 | -u consumer_key:consumer_secret 169 | ``` 170 | 171 | ```javascript 172 | WooCommerce.get('products/tags', function(err, data, res) { 173 | console.log(res); 174 | }); 175 | ``` 176 | 177 | ```php 178 | get('products/tags')); ?> 179 | ``` 180 | 181 | ```python 182 | print(wcapi.get("products/tags").json()) 183 | ``` 184 | 185 | ```ruby 186 | woocommerce.get("products/tags").parsed_response 187 | ``` 188 | 189 | > JSON response example: 190 | 191 | ```json 192 | { 193 | "product_tags": [ 194 | { 195 | "id": 37, 196 | "name": "Leather Shoes", 197 | "slug": "leather-shoes", 198 | "description": "", 199 | "count": 0 200 | }, 201 | { 202 | "id": 38, 203 | "name": "Oxford Shoes", 204 | "slug": "oxford-shoes", 205 | "description": "", 206 | "count": 0 207 | } 208 | ] 209 | } 210 | ``` 211 | 212 | 215 | 216 | ## Update a Product Tag ## 217 | 218 | This API lets you make changes to a product tag. 219 | 220 | ### HTTP Request ### 221 | 222 |
223 |
224 | PUT 225 |
/wc-api/v3/products/tags/<id>
226 |
227 |
228 | 229 | ```shell 230 | curl -X PUT https://example.com/wc-api/v3/products/tags/37 \ 231 | -u consumer_key:consumer_secret \ 232 | -H "Content-Type: application/json" \ 233 | -d '{ 234 | "product_tag": { 235 | "description": "Genuine leather." 236 | } 237 | }' 238 | ``` 239 | 240 | ```javascript 241 | var data = { 242 | product_tag: { 243 | description: 'Genuine leather.' 244 | } 245 | }; 246 | 247 | WooCommerce.put('products/tags/37', data, function(err, data, res) { 248 | console.log(res); 249 | }); 250 | ``` 251 | 252 | ```php 253 | put('products/tags/37', $data)); 261 | ?> 262 | ``` 263 | 264 | ```python 265 | data = { 266 | "product_tag": { 267 | "description": "Genuine leather." 268 | } 269 | } 270 | 271 | print(wcapi.put("products/tags/37", data).json()) 272 | ``` 273 | 274 | ```ruby 275 | data = { 276 | product_tag: { 277 | description: "Genuine leather." 278 | } 279 | } 280 | 281 | woocommerce.put("products/tags/37", data).parsed_response 282 | ``` 283 | 284 | > JSON response example: 285 | 286 | ```json 287 | { 288 | "product_tag": { 289 | "id": 37, 290 | "name": "Leather Shoes", 291 | "slug": "leather-shoes", 292 | "description": "Genuine leather.", 293 | "count": 0 294 | } 295 | } 296 | ``` 297 | 298 | 301 | 302 | ## Delete a Product Tag ## 303 | 304 | This API helps you delete a product tag. 305 | 306 | ### HTTP Request ### 307 | 308 |
309 |
310 | DELETE 311 |
/wc-api/v3/products/tags/<id>
312 |
313 |
314 | 315 | ```shell 316 | curl -X DELETE https://example.com/wc-api/v3/products/tags/37 \ 317 | -u consumer_key:consumer_secret 318 | ``` 319 | 320 | ```javascript 321 | WooCommerce.delete('products/tags/37', function(err, data, res) { 322 | console.log(res); 323 | }); 324 | ``` 325 | 326 | ```php 327 | delete('products/tags/37')); ?> 328 | ``` 329 | 330 | ```python 331 | print(wcapi.delete("products/tags/37").json()) 332 | ``` 333 | 334 | ```ruby 335 | woocommerce.delete("products/tags/37").parsed_response 336 | ``` 337 | 338 | > JSON response example: 339 | 340 | ```json 341 | { 342 | "message": "Deleted product_tag" 343 | } 344 | ``` 345 | 346 | 349 | -------------------------------------------------------------------------------- /source/includes/v3/_reports.md: -------------------------------------------------------------------------------- 1 | # Reports # 2 | 3 | This section lists all API endpoints that can be used view reports. 4 | 5 | ## Reports Filters ## 6 | 7 | Use the following filters for any type of report to specify the period of sales: 8 | 9 | | Filter | Type | Description | 10 | | ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 11 | | `period` | string | The supported periods are: `week`, `month`, `last_month`, and `year`. If you use an invalid period, `week` is used. If you don't specify a period, the current day is used | 12 | | `date_min` | string | Return sales for a specific start date. The date need to be in the `YYYY-MM-DD` format | 13 | | `date_max` | string | Return sales for a specific end date. The dates need to be in the `YYYY-MM-DD` format. Required to set the `filter[date_min]` too | 14 | 15 | ## View List of Reports ## 16 | 17 | This API lets you retrieve and view a simple list of available reports. 18 | 19 | ### HTTP Request ### 20 | 21 |
22 |
23 | GET 24 |
/wc-api/v3/reports
25 |
26 |
27 | 28 | ```shell 29 | curl https://example.com/wc-api/v3/reports \ 30 | -u consumer_key:consumer_secret 31 | ``` 32 | 33 | ```javascript 34 | WooCommerce.get('reports', function(err, data, res) { 35 | console.log(res); 36 | }); 37 | ``` 38 | 39 | ```php 40 | get('reports')); ?> 41 | ``` 42 | 43 | ```python 44 | print(wcapi.get("reports").json()) 45 | ``` 46 | 47 | ```ruby 48 | woocommerce.get("reports").parsed_response 49 | ``` 50 | 51 | > JSON response example: 52 | 53 | ```json 54 | { 55 | "reports": [ 56 | "sales", 57 | "sales/top_sellers" 58 | ] 59 | } 60 | ``` 61 | 62 | ## View List of Sales Report ## 63 | 64 | This API lets you retrieve and view a list of sales report. 65 | 66 | ### HTTP Request ### 67 | 68 |
69 |
70 | GET 71 |
/wc-api/v3/reports/sales
72 |
73 |
74 | 75 | ```shell 76 | curl https://example.com/wc-api/v3/reports/sales?filter[date_min]=2015-01-18&filter[date_max]=2015-01-21 \ 77 | -u consumer_key:consumer_secret 78 | ``` 79 | 80 | ```javascript 81 | WooCommerce.get('reports/sales?filter[date_min]=2015-01-18&filter[date_max]=2015-01-21', function(err, data, res) { 82 | console.log(res); 83 | }); 84 | ``` 85 | 86 | ```php 87 | [ 90 | 'date_min' => '2015-01-18', 91 | 'date_max' => '2015-01-21' 92 | ] 93 | ]; 94 | 95 | print_r($woocommerce->get('reports/sales', $query)); 96 | ?> 97 | ``` 98 | 99 | ```python 100 | print(wcapi.get("reports/sales?filter[date_min]=2015-01-18&filter[date_max]=2015-01-21").json()) 101 | ``` 102 | 103 | ```ruby 104 | query = { 105 | filter: { 106 | date_min: "2015-01-18", 107 | date_max: "2015-01-21" 108 | } 109 | } 110 | 111 | woocommerce.get("reports/sales", query).parsed_response 112 | ``` 113 | 114 | > JSON response example: 115 | 116 | ```json 117 | { 118 | "sales": { 119 | "total_sales": "580.10", 120 | "average_sales": "145.03", 121 | "total_orders": 4, 122 | "total_items": 31, 123 | "total_tax": "26.10", 124 | "total_shipping": "20.00", 125 | "total_discount": "0.00", 126 | "totals_grouped_by": "day", 127 | "totals": { 128 | "2015-01-18": { 129 | "sales": "-17.00", 130 | "orders": 1, 131 | "items": 1, 132 | "tax": "0.00", 133 | "shipping": "0.00", 134 | "discount": "0.00", 135 | "customers": 0 136 | }, 137 | "2015-01-19": { 138 | "sales": "0.00", 139 | "orders": 0, 140 | "items": 0, 141 | "tax": "0.00", 142 | "shipping": "0.00", 143 | "discount": "0.00", 144 | "customers": 0 145 | }, 146 | "2015-01-20": { 147 | "sales": "0.00", 148 | "orders": 0, 149 | "items": 0, 150 | "tax": "0.00", 151 | "shipping": "0.00", 152 | "discount": "0.00", 153 | "customers": 0 154 | }, 155 | "2015-01-21": { 156 | "sales": "597.10", 157 | "orders": 3, 158 | "items": 30, 159 | "tax": "26.10", 160 | "shipping": "20.00", 161 | "discount": "0.00", 162 | "customers": 0 163 | } 164 | }, 165 | "total_customers": 0 166 | } 167 | } 168 | ``` 169 | 170 | ## View List of Top Sellers Report ## 171 | 172 | This API lets you retrieve and view a list of top sellers report. 173 | 174 | ### HTTP Request ### 175 | 176 |
177 |
178 | GET 179 |
/wc-api/v3/reports/sales/top_sellers
180 |
181 |
182 | 183 | ```shell 184 | curl https://example.com/wc-api/v3/reports/sales/top_sellers?filter[period]=last_month \ 185 | -u consumer_key:consumer_secret 186 | ``` 187 | 188 | ```javascript 189 | WooCommerce.get('reports/sales/top_sellers?filter[period]=last_month', function(err, data, res) { 190 | console.log(res); 191 | }); 192 | ``` 193 | 194 | ```php 195 | [ 198 | 'period' => 'last_month' 199 | ] 200 | ]; 201 | 202 | print_r($woocommerce->get('reports/sales/top_sellers', $query)); 203 | ?> 204 | ``` 205 | 206 | ```python 207 | print(wcapi.get("reports/sales/top_sellers?filter[period]=last_month").json()) 208 | ``` 209 | 210 | ```ruby 211 | query = { 212 | filter: { 213 | period: "last_month" 214 | } 215 | } 216 | 217 | woocommerce.get("reports/sales/top_sellers", query).parsed_response 218 | ``` 219 | 220 | > JSON response example: 221 | 222 | ```json 223 | { 224 | "top_sellers": [ 225 | { 226 | "title": "Happy Ninja", 227 | "product_id": "37", 228 | "quantity": "24" 229 | }, 230 | { 231 | "title": "Flying Ninja", 232 | "product_id": "70", 233 | "quantity": "14" 234 | }, 235 | { 236 | "title": "Happy Ninja", 237 | "product_id": "53", 238 | "quantity": "6" 239 | }, 240 | { 241 | "title": "Ninja Silhouette", 242 | "product_id": "31", 243 | "quantity": "3" 244 | }, 245 | { 246 | "title": "Woo Logo", 247 | "product_id": "15", 248 | "quantity": "3" 249 | }, 250 | { 251 | "title": "Woo Album #1", 252 | "product_id": "83", 253 | "quantity": "3" 254 | }, 255 | { 256 | "title": "Woo Album #4", 257 | "product_id": "96", 258 | "quantity": "1" 259 | }, 260 | { 261 | "title": "Premium Quality", 262 | "product_id": "19", 263 | "quantity": "1" 264 | }, 265 | { 266 | "title": "Ninja Silhouette", 267 | "product_id": "56", 268 | "quantity": "1" 269 | } 270 | ] 271 | } 272 | ``` 273 | -------------------------------------------------------------------------------- /source/includes/v3/_tax-classes.md: -------------------------------------------------------------------------------- 1 | # Tax - Classes # 2 | 3 | This section lists all API endpoints that can be used to create, edit or otherwise manipulate tax classes. 4 | 5 | ## Taxes Properties ## 6 | 7 | | Attribute | Type | Description | 8 | | --------- | ------ | -------------------------------------------------------- | 9 | | `slug` | string | Tax class slug read-only | 10 | | `name` | string | Tax class name | 11 | 12 | ## Create a Tax Class ## 13 | 14 | This API helps you to create a new tax class. 15 | 16 | ### HTTP Request ### 17 | 18 |
19 |
20 | POST 21 |
/wc-api/v3/taxes/classes
22 |
23 |
24 | 25 | ```shell 26 | curl -X POST https://example.com/wc-api/v3/taxes/classes \ 27 | -u consumer_key:consumer_secret \ 28 | -H "Content-Type: application/json" \ 29 | -d '{ 30 | "tax_class": { 31 | "name": "Zero Rate" 32 | } 33 | }' 34 | ``` 35 | 36 | ```javascript 37 | var data = { 38 | tax_class: { 39 | name: 'Zero Rate' 40 | } 41 | }; 42 | 43 | WooCommerce.post('taxes/classes', data, function(err, data, res) { 44 | console.log(res); 45 | }); 46 | ``` 47 | 48 | ```php 49 | [ 52 | 'name' => 'Zero Rate' 53 | ] 54 | ]; 55 | 56 | print_r($woocommerce->post('taxes/classes', $data)); 57 | ?> 58 | ``` 59 | 60 | ```python 61 | data = { 62 | "tax_class": { 63 | "name": "Zero Rate" 64 | } 65 | } 66 | 67 | print(wcapi.post("taxes/classes", data).json()) 68 | ``` 69 | 70 | ```ruby 71 | data = { 72 | tax_class: { 73 | name: "Zero Rate" 74 | } 75 | } 76 | 77 | woocommerce.post("taxes/classes", data).parsed_response 78 | ``` 79 | 80 | > JSON response example: 81 | 82 | ```json 83 | { 84 | "tax_class": { 85 | "slug": "zero-rate", 86 | "name": "Zero Rate" 87 | } 88 | } 89 | ``` 90 | 91 | 94 | 95 | ## View List of Tax Classes ## 96 | 97 | This API helps you to view all the tax classes. 98 | 99 | ### HTTP Request ### 100 | 101 |
102 |
103 | GET 104 |
/wc-api/v3/taxes/classes
105 |
106 |
107 | 108 | ```shell 109 | curl https://example.com/wc-api/v3/taxes/classes \ 110 | -u consumer_key:consumer_secret 111 | ``` 112 | 113 | ```javascript 114 | WooCommerce.get('taxes/classes', function(err, data, res) { 115 | console.log(res); 116 | }); 117 | ``` 118 | 119 | ```php 120 | get('taxes/classes')); ?> 121 | ``` 122 | 123 | ```python 124 | print(wcapi.get("taxes/classes").json()) 125 | ``` 126 | 127 | ```ruby 128 | woocommerce.get("taxes/classes").parsed_response 129 | ``` 130 | 131 | > JSON response example: 132 | 133 | ```json 134 | { 135 | "tax_classes": [ 136 | { 137 | "slug": "standard", 138 | "name": "Standard Rate" 139 | }, 140 | { 141 | "slug": "reduced-rate", 142 | "name": "Reduced Rate" 143 | }, 144 | { 145 | "slug": "zero-rate", 146 | "name": "Zero Rate" 147 | } 148 | ] 149 | } 150 | ``` 151 | 152 | 155 | 156 | ## Delete a Tax Class ## 157 | 158 | This API helps you delete a tax class. 159 | 160 | 163 | 164 | ### HTTP Request ### 165 | 166 |
167 |
168 | DELETE 169 |
/wc-api/v3/taxes/classes/<slug>
170 |
171 |
172 | 173 | ```shell 174 | curl -X DELETE https://example.com/wc-api/v3/taxes/classes/zero-rate \ 175 | -u consumer_key:consumer_secret 176 | ``` 177 | 178 | ```javascript 179 | WooCommerce.delete('taxes/classes/zero-rate', function(err, data, res) { 180 | console.log(res); 181 | }); 182 | ``` 183 | 184 | ```php 185 | delete('taxes/classes/zero-rate')); ?> 186 | ``` 187 | 188 | ```python 189 | print(wcapi.delete("taxes/classes/zero-rate").json()) 190 | ``` 191 | 192 | ```ruby 193 | woocommerce.delete("taxes/classes/zero-rate").parsed_response 194 | ``` 195 | 196 | > JSON response example: 197 | 198 | ```json 199 | { 200 | "message": "Deleted tax_class" 201 | } 202 | ``` 203 | 204 | 207 | 208 | ## View Tax Rate Count ## 209 | 210 | This API lets you retrieve a count of all tax rates. 211 | 212 | ### HTTP Request ### 213 | 214 |
215 |
216 | GET 217 |
/wc-api/v3/taxes/classes/count
218 |
219 |
220 | 221 | ```shell 222 | curl https://example.com/wc-api/v3/taxes/classes/count \ 223 | -u consumer_key:consumer_secret 224 | ``` 225 | 226 | ```javascript 227 | WooCommerce.get('taxes/classes/count', function(err, data, res) { 228 | console.log(res); 229 | }); 230 | ``` 231 | 232 | ```php 233 | get('taxes/classes/count')); ?> 234 | ``` 235 | 236 | ```python 237 | print(wcapi.get("taxes/classes/count").json()) 238 | ``` 239 | 240 | ```ruby 241 | woocommerce.get("taxes/classes/count").parsed_response 242 | ``` 243 | 244 | > JSON response example: 245 | 246 | ```json 247 | { 248 | "count": 3 249 | } 250 | ``` 251 | 252 | 255 | -------------------------------------------------------------------------------- /source/includes/wp-api-v1/_order-notes.md: -------------------------------------------------------------------------------- 1 | # Order notes # 2 | 3 | The order notes API allows you to create, view, and delete individual order notes. 4 | Order notes are added by administrators and programmatically to store data about an order, or order events. 5 | 6 | ## Order note properties ## 7 | 8 | | Attribute | Type | Description | 9 | |-----------------|-----------|---------------------------------------------------------------------------------------------------------------------| 10 | | `id` | integer | Unique identifier for the resource. read-only | 11 | | `date_created` | date-time | The date the order note was created, in the site's timezone. read-only | 12 | | `note` | string | Order note. required | 13 | | `customer_note` | boolean | Shows/define if the note is only for reference or for the customer (the user will be notified). Default is `false`. | 14 | 15 | ## Create an order note ## 16 | 17 | This API helps you to create a new note for an order. 18 | 19 | ### HTTP request ### 20 | 21 |
22 |
23 | POST 24 |
/wp-json/wc/v1/orders/<id>/notes
25 |
26 |
27 | 28 | ```shell 29 | curl -X POST https://example.com/wp-json/wc/v1/orders/645/notes \ 30 | -u consumer_key:consumer_secret \ 31 | -H "Content-Type: application/json" \ 32 | -d '{ 33 | "note": "Order ok!!!" 34 | }' 35 | ``` 36 | 37 | ```javascript 38 | const data = { 39 | note: "Order ok!!!" 40 | }; 41 | 42 | WooCommerce.post("orders/645/notes", data) 43 | .then((response) => { 44 | console.log(response.data); 45 | }) 46 | .catch((error) => { 47 | console.log(error.response.data); 48 | }); 49 | ``` 50 | 51 | ```php 52 | 'Order ok!!!' 55 | ]; 56 | 57 | print_r($woocommerce->post('orders/645/notes', $data)); 58 | ?> 59 | ``` 60 | 61 | ```python 62 | data = { 63 | "note": "Order ok!!!" 64 | } 65 | 66 | print(wcapi.post("orders/645/notes", data).json()) 67 | ``` 68 | 69 | ```ruby 70 | data = { 71 | note: "Order ok!!!" 72 | } 73 | 74 | woocommerce.post("orders/645/notes", data).parsed_response 75 | ``` 76 | 77 | > JSON response example: 78 | 79 | ```json 80 | { 81 | "id": 51, 82 | "date_created": "2016-05-13T20:51:55", 83 | "note": "Order ok!!!", 84 | "customer_note": false, 85 | "_links": { 86 | "self": [ 87 | { 88 | "href": "https://example.com/wp-json/wc/v1/orders/118/notes/51" 89 | } 90 | ], 91 | "collection": [ 92 | { 93 | "href": "https://example.com/wp-json/wc/v1/orders/118/notes" 94 | } 95 | ], 96 | "up": [ 97 | { 98 | "href": "https://example.com/wp-json/wc/v1/orders/118" 99 | } 100 | ] 101 | } 102 | } 103 | ``` 104 | 105 | ## Retrieve an order note ## 106 | 107 | This API lets you retrieve and view a specific note from an order. 108 | 109 | ### HTTP request ### 110 | 111 |
112 |
113 | GET 114 |
/wp-json/wc/v1/orders/<id>/notes/<note_id>
115 |
116 |
117 | 118 | ```shell 119 | curl https://example.com/wp-json/wc/v1/orders/645/notes/51 \ 120 | -u consumer_key:consumer_secret 121 | ``` 122 | 123 | ```javascript 124 | WooCommerce.get("orders/645/notes/51") 125 | .then((response) => { 126 | console.log(response.data); 127 | }) 128 | .catch((error) => { 129 | console.log(error.response.data); 130 | }); 131 | ``` 132 | 133 | ```php 134 | get('orders/645/notes/51')); ?> 135 | ``` 136 | 137 | ```python 138 | print(wcapi.get("orders/645/notes/51").json()) 139 | ``` 140 | 141 | ```ruby 142 | woocommerce.get("orders/645/notes/51").parsed_response 143 | ``` 144 | 145 | > JSON response example: 146 | 147 | ```json 148 | { 149 | "id": 51, 150 | "date_created": "2016-05-13T20:51:55", 151 | "note": "Order ok!!!", 152 | "customer_note": false, 153 | "_links": { 154 | "self": [ 155 | { 156 | "href": "https://example.com/wp-json/wc/v1/orders/118/notes/51" 157 | } 158 | ], 159 | "collection": [ 160 | { 161 | "href": "https://example.com/wp-json/wc/v1/orders/118/notes" 162 | } 163 | ], 164 | "up": [ 165 | { 166 | "href": "https://example.com/wp-json/wc/v1/orders/118" 167 | } 168 | ] 169 | } 170 | } 171 | ``` 172 | 173 | ## List all order notes ## 174 | 175 | This API helps you to view all the notes from an order. 176 | 177 | ### HTTP request ### 178 | 179 |
180 |
181 | GET 182 |
/wp-json/wc/v1/orders/<id>/notes
183 |
184 |
185 | 186 | ```shell 187 | curl https://example.com/wp-json/wc/v1/orders/645/notes \ 188 | -u consumer_key:consumer_secret 189 | ``` 190 | 191 | ```javascript 192 | WooCommerce.get("orders/645/notes") 193 | .then((response) => { 194 | console.log(response.data); 195 | }) 196 | .catch((error) => { 197 | console.log(error.response.data); 198 | }); 199 | ``` 200 | 201 | ```php 202 | get('orders/645/notes')); ?> 203 | ``` 204 | 205 | ```python 206 | print(wcapi.get("orders/645/notes").json()) 207 | ``` 208 | 209 | ```ruby 210 | woocommerce.get("orders/645/notes").parsed_response 211 | ``` 212 | 213 | > JSON response example: 214 | 215 | ```json 216 | [ 217 | { 218 | "id": 51, 219 | "date_created": "2016-05-13T20:51:55", 220 | "note": "Order ok!!!", 221 | "customer_note": false, 222 | "_links": { 223 | "self": [ 224 | { 225 | "href": "https://example.com/wp-json/wc/v1/orders/118/notes/51" 226 | } 227 | ], 228 | "collection": [ 229 | { 230 | "href": "https://example.com/wp-json/wc/v1/orders/118/notes" 231 | } 232 | ], 233 | "up": [ 234 | { 235 | "href": "https://example.com/wp-json/wc/v1/orders/118" 236 | } 237 | ] 238 | } 239 | }, 240 | { 241 | "id": 46, 242 | "date_created": "2016-05-03T18:10:43", 243 | "note": "Order status changed from Pending Payment to Processing.", 244 | "customer_note": false, 245 | "_links": { 246 | "self": [ 247 | { 248 | "href": "https://example.com/wp-json/wc/v1/orders/118/notes/46" 249 | } 250 | ], 251 | "collection": [ 252 | { 253 | "href": "https://example.com/wp-json/wc/v1/orders/118/notes" 254 | } 255 | ], 256 | "up": [ 257 | { 258 | "href": "https://example.com/wp-json/wc/v1/orders/118" 259 | } 260 | ] 261 | } 262 | } 263 | ] 264 | ``` 265 | 266 | ## Delete an order note ## 267 | 268 | This API helps you delete an order note. 269 | 270 | ### HTTP request ### 271 | 272 |
273 |
274 | DELETE 275 |
/wp-json/wc/v1/orders/<id>/notes/<note_id>
276 |
277 |
278 | 279 | ```shell 280 | curl -X DELETE https://example.com/wp-json/wc/v1/orders/645/notes/51?force=true \ 281 | -u consumer_key:consumer_secret 282 | ``` 283 | 284 | ```javascript 285 | WooCommerce.delete("orders/645/notes/51", { 286 | force: true 287 | }) 288 | .then((response) => { 289 | console.log(response.data); 290 | }) 291 | .catch((error) => { 292 | console.log(error.response.data); 293 | }); 294 | ``` 295 | 296 | ```php 297 | delete('orders/645/notes/51', ['force' => true])); ?> 298 | ``` 299 | 300 | ```python 301 | print(wcapi.delete("orders/645/notes/51", params={"force": True}).json()) 302 | ``` 303 | 304 | ```ruby 305 | woocommerce.delete("orders/645/notes/51", force: true).parsed_response 306 | ``` 307 | 308 | > JSON response example: 309 | 310 | ```json 311 | { 312 | "id": 51, 313 | "date_created": "2016-05-13T20:51:55", 314 | "note": "Order ok!!!", 315 | "customer_note": false, 316 | "_links": { 317 | "self": [ 318 | { 319 | "href": "https://example.com/wp-json/wc/v1/orders/118/notes/51" 320 | } 321 | ], 322 | "collection": [ 323 | { 324 | "href": "https://example.com/wp-json/wc/v1/orders/118/notes" 325 | } 326 | ], 327 | "up": [ 328 | { 329 | "href": "https://example.com/wp-json/wc/v1/orders/118" 330 | } 331 | ] 332 | } 333 | } 334 | ``` 335 | #### Available parameters #### 336 | 337 | | Parameter | Type | Description | 338 | |-----------|--------|---------------------------------------------------------------| 339 | | `force` | string | Required to be `true`, as resource does not support trashing. | 340 | -------------------------------------------------------------------------------- /source/includes/wp-api-v1/_tax-classes.md: -------------------------------------------------------------------------------- 1 | # Tax classes # 2 | 3 | The tax classes API allows you to create, view, and delete individual tax classes. 4 | 5 | ## Tax class properties ## 6 | 7 | | Attribute | Type | Description | 8 | |-----------|--------|-------------------------------------------------------------------------------| 9 | | `slug` | string | Unique identifier for the resource. read-only | 10 | | `name` | string | Tax class name. required | 11 | 12 | ## Create a tax class ## 13 | 14 | This API helps you to create a new tax class. 15 | 16 | ### HTTP request ### 17 | 18 |
19 |
20 | POST 21 |
/wp-json/wc/v1/taxes/classes
22 |
23 |
24 | 25 | ```shell 26 | curl -X POST https://example.com/wp-json/wc/v1/taxes/classes \ 27 | -u consumer_key:consumer_secret \ 28 | -H "Content-Type: application/json" \ 29 | -d '{ 30 | "name": "Zero Rate" 31 | }' 32 | ``` 33 | 34 | ```javascript 35 | const data = { 36 | name: "Zero Rate" 37 | }; 38 | 39 | WooCommerce.post("taxes/classes", data) 40 | .then((response) => { 41 | console.log(response.data); 42 | }) 43 | .catch((error) => { 44 | console.log(error.response.data); 45 | }); 46 | ``` 47 | 48 | ```php 49 | 'Zero Rate' 52 | ]; 53 | 54 | print_r($woocommerce->post('taxes/classes', $data)); 55 | ?> 56 | ``` 57 | 58 | ```python 59 | data = { 60 | "name": "Zero Rate" 61 | } 62 | 63 | print(wcapi.post("taxes/classes", data).json()) 64 | ``` 65 | 66 | ```ruby 67 | data = { 68 | name: "Zero Rate" 69 | } 70 | 71 | woocommerce.post("taxes/classes", data).parsed_response 72 | ``` 73 | 74 | > JSON response example: 75 | 76 | ```json 77 | { 78 | "slug": "zero-rate", 79 | "name": "Zero Rate", 80 | "_links": { 81 | "collection": [ 82 | { 83 | "href": "https://example.com/wp-json/wc/v1/taxes/classes" 84 | } 85 | ] 86 | } 87 | } 88 | ``` 89 | 90 | ## List all tax classes ## 91 | 92 | This API helps you to view all tax classes. 93 | 94 | ### HTTP request ### 95 | 96 |
97 |
98 | GET 99 |
/wp-json/wc/v1/taxes/classes
100 |
101 |
102 | 103 | ```shell 104 | curl https://example.com/wp-json/wc/v1/taxes/classes \ 105 | -u consumer_key:consumer_secret 106 | ``` 107 | 108 | ```javascript 109 | WooCommerce.get("taxes/classes") 110 | .then((response) => { 111 | console.log(response.data); 112 | }) 113 | .catch((error) => { 114 | console.log(error.response.data); 115 | }); 116 | ``` 117 | 118 | ```php 119 | get('taxes/classes')); ?> 120 | ``` 121 | 122 | ```python 123 | print(wcapi.get("taxes/classes").json()) 124 | ``` 125 | 126 | ```ruby 127 | woocommerce.get("taxes/classes").parsed_response 128 | ``` 129 | 130 | > JSON response example: 131 | 132 | ```json 133 | [ 134 | { 135 | "slug": "standard", 136 | "name": "Standard Rate", 137 | "_links": { 138 | "collection": [ 139 | { 140 | "href": "https://example.com/wp-json/wc/v1/taxes/classes" 141 | } 142 | ] 143 | } 144 | }, 145 | { 146 | "slug": "reduced-rate", 147 | "name": "Reduced Rate", 148 | "_links": { 149 | "collection": [ 150 | { 151 | "href": "https://example.com/wp-json/wc/v1/taxes/classes" 152 | } 153 | ] 154 | } 155 | }, 156 | { 157 | "slug": "zero-rate", 158 | "name": "Zero Rate", 159 | "_links": { 160 | "collection": [ 161 | { 162 | "href": "https://example.com/wp-json/wc/v1/taxes/classes" 163 | } 164 | ] 165 | } 166 | } 167 | ] 168 | ``` 169 | 170 | ## Delete a tax class ## 171 | 172 | This API helps you delete a tax class. 173 | 174 | 177 | 178 | ### HTTP request ### 179 | 180 |
181 |
182 | DELETE 183 |
/wp-json/wc/v1/taxes/classes/<slug>
184 |
185 |
186 | 187 | ```shell 188 | curl -X DELETE https://example.com/wp-json/wc/v1/taxes/classes/zero-rate?force=true \ 189 | -u consumer_key:consumer_secret 190 | ``` 191 | 192 | ```javascript 193 | WooCommerce.delete("taxes/classes/zero-rate", { 194 | force: true 195 | }) 196 | .then((response) => { 197 | console.log(response.data); 198 | }) 199 | .catch((error) => { 200 | console.log(error.response.data); 201 | }); 202 | ``` 203 | 204 | ```php 205 | delete('taxes/classes/zero-rate', ['force' => true])); ?> 206 | ``` 207 | 208 | ```python 209 | print(wcapi.delete("taxes/classes/zero-rate", params={"force": True}).json()) 210 | ``` 211 | 212 | ```ruby 213 | woocommerce.delete("taxes/classes/zero-rate", force: true).parsed_response 214 | ``` 215 | 216 | > JSON response example: 217 | 218 | ```json 219 | { 220 | "slug": "zero-rate", 221 | "name": "Zero Rate", 222 | "_links": { 223 | "collection": [ 224 | { 225 | "href": "https://example.com/wp-json/wc/v1/taxes/classes" 226 | } 227 | ] 228 | } 229 | } 230 | ``` 231 | 232 | #### Available parameters #### 233 | 234 | | Parameter | Type | Description | 235 | |-----------|--------|---------------------------------------------------------------| 236 | | `force` | string | Required to be `true`, since this resource does not support trashing. | 237 | -------------------------------------------------------------------------------- /source/includes/wp-api-v2/_shipping-methods.md: -------------------------------------------------------------------------------- 1 | # Shipping methods # 2 | 3 | The shipping methods API allows you to view individual shipping methods. 4 | 5 | ## Shipping method properties ## 6 | 7 | | Attribute | Type | Description | 8 | | ------------- | ------ | ---------------------------------------------------------------------- | 9 | | `id` | string | Method ID. read-only | 10 | | `title` | string | Shipping method title. read-only | 11 | | `description` | string | Shipping method description. read-only | 12 | 13 | ## Retrieve a shipping method ## 14 | 15 | This API lets you retrieve and view a specific shipping method. 16 | 17 | ### HTTP request ### 18 | 19 |
20 |
21 | GET 22 |
/wp-json/wc/v2/shipping_methods/<id>
23 |
24 |
25 | 26 | ```shell 27 | curl https://example.com/wp-json/wc/v2/shipping_methods/flat_rate \ 28 | -u consumer_key:consumer_secret 29 | ``` 30 | 31 | ```javascript 32 | WooCommerce.get("shipping_methods/flat_rate") 33 | .then((response) => { 34 | console.log(response.data); 35 | }) 36 | .catch((error) => { 37 | console.log(error.response.data); 38 | }); 39 | ``` 40 | 41 | ```php 42 | get('shipping_methods/flat_rate')); ?> 43 | ``` 44 | 45 | ```python 46 | print(wcapi.get("shipping_methods/flat_rate").json()) 47 | ``` 48 | 49 | ```ruby 50 | woocommerce.get("shipping_methods/flat_rate").parsed_response 51 | ``` 52 | 53 | > JSON response example: 54 | 55 | ```json 56 | { 57 | "id": "flat_rate", 58 | "title": "Flat rate", 59 | "description": "Lets you charge a fixed rate for shipping.", 60 | "_links": { 61 | "self": [ 62 | { 63 | "href": "https://example.com/wp-json/wc/v2/shipping_methods/flat_rate" 64 | } 65 | ], 66 | "collection": [ 67 | { 68 | "href": "https://example.com/wp-json/wc/v2/shipping_methods" 69 | } 70 | ] 71 | } 72 | } 73 | ``` 74 | 75 | ## List all shipping methods ## 76 | 77 | This API helps you to view all the shipping methods. 78 | 79 | ### HTTP request ### 80 | 81 |
82 |
83 | GET 84 |
/wp-json/wc/v2/shipping_methods
85 |
86 |
87 | 88 | ```shell 89 | curl https://example.com/wp-json/wc/v2/shipping_methods \ 90 | -u consumer_key:consumer_secret 91 | ``` 92 | 93 | ```javascript 94 | WooCommerce.get("shipping_methods") 95 | .then((response) => { 96 | console.log(response.data); 97 | }) 98 | .catch((error) => { 99 | console.log(error.response.data); 100 | }); 101 | ``` 102 | 103 | ```php 104 | get('shipping_methods')); ?> 105 | ``` 106 | 107 | ```python 108 | print(wcapi.get("shipping_methods").json()) 109 | ``` 110 | 111 | ```ruby 112 | woocommerce.get("shipping_methods").parsed_response 113 | ``` 114 | 115 | > JSON response example: 116 | 117 | ```json 118 | [ 119 | { 120 | "id": "flat_rate", 121 | "title": "Flat rate", 122 | "description": "Lets you charge a fixed rate for shipping.", 123 | "_links": { 124 | "self": [ 125 | { 126 | "href": "https://example.com/wp-json/wc/v2/shipping_methods/flat_rate" 127 | } 128 | ], 129 | "collection": [ 130 | { 131 | "href": "https://example.com/wp-json/wc/v2/shipping_methods" 132 | } 133 | ] 134 | } 135 | }, 136 | { 137 | "id": "free_shipping", 138 | "title": "Free shipping", 139 | "description": "Free shipping is a special method which can be triggered with coupons and minimum spends.", 140 | "_links": { 141 | "self": [ 142 | { 143 | "href": "https://example.com/wp-json/wc/v2/shipping_methods/free_shipping" 144 | } 145 | ], 146 | "collection": [ 147 | { 148 | "href": "https://example.com/wp-json/wc/v2/shipping_methods" 149 | } 150 | ] 151 | } 152 | }, 153 | { 154 | "id": "local_pickup", 155 | "title": "Local pickup", 156 | "description": "Allow customers to pick up orders themselves. By default, when using local pickup store base taxes will apply regardless of customer address.", 157 | "_links": { 158 | "self": [ 159 | { 160 | "href": "https://example.com/wp-json/wc/v2/shipping_methods/local_pickup" 161 | } 162 | ], 163 | "collection": [ 164 | { 165 | "href": "https://example.com/wp-json/wc/v2/shipping_methods" 166 | } 167 | ] 168 | } 169 | } 170 | ] 171 | ``` 172 | -------------------------------------------------------------------------------- /source/includes/wp-api-v2/_shipping-zone-locations.md: -------------------------------------------------------------------------------- 1 | # Shipping zone locations # 2 | 3 | The shipping zone locations API allows you to view and batch update locations of a shipping zone. 4 | 5 | ## Shipping location properties ## 6 | 7 | | Attribute | Type | Description | 8 | | --------- | ------ | ----------------------------------------------------------------------------------------------------------- | 9 | | `code` | string | Shipping zone location code. | 10 | | `type` | string | Shipping zone location type. Options: `postcode`, `state`, `country` and `continent`. Default is `country`. | 11 | 12 | ## List all locations of a shipping zone ## 13 | 14 | This API helps you to view all the locations of a shipping zone. 15 | 16 | ### HTTP request ### 17 | 18 |
19 |
20 | GET 21 |
/wp-json/wc/v2/shipping/zones/<id>/locations
22 |
23 |
24 | 25 | ```shell 26 | curl https://example.com/wp-json/wc/v2/shipping/zones/5/locations \ 27 | -u consumer_key:consumer_secret 28 | ``` 29 | 30 | ```javascript 31 | WooCommerce.get("shipping/zones/5/locations") 32 | .then((response) => { 33 | console.log(response.data); 34 | }) 35 | .catch((error) => { 36 | console.log(error.response.data); 37 | }); 38 | ``` 39 | 40 | ```php 41 | get('shipping/zones/5/locations')); ?> 42 | ``` 43 | 44 | ```python 45 | print(wcapi.get("shipping/zones/5/locations").json()) 46 | ``` 47 | 48 | ```ruby 49 | woocommerce.get("shipping/zones/5/locations").parsed_response 50 | ``` 51 | 52 | > JSON response example: 53 | 54 | ```json 55 | [ 56 | { 57 | "code": "BR", 58 | "type": "country", 59 | "_links": { 60 | "collection": [ 61 | { 62 | "href": "https://example.com/wp-json/wc/v2/shipping/zones/5/locations" 63 | } 64 | ], 65 | "describes": [ 66 | { 67 | "href": "https://example.com/wp-json/wc/v2/shipping/zones/5" 68 | } 69 | ] 70 | } 71 | } 72 | ] 73 | ``` 74 | 75 | ## Update a locations of a shipping zone ## 76 | 77 | This API lets you make changes to locations of a shipping zone. 78 | 79 | ### HTTP request ### 80 | 81 |
82 |
83 | PUT 84 |
/wp-json/wc/v2/shipping/zones/<id>/locations
85 |
86 |
87 | 88 | ```shell 89 | curl -X PUT https://example.com/wp-json/wc/v2/shipping/zones/5/locations \ 90 | -u consumer_key:consumer_secret \ 91 | -H "Content-Type: application/json" \ 92 | -d '[ 93 | { 94 | "code": "BR:SP", 95 | "type": "state" 96 | }, 97 | { 98 | "code": "BR:RJ", 99 | "type": "state" 100 | } 101 | ]' 102 | ``` 103 | 104 | ```javascript 105 | var data = [ 106 | { 107 | code: 'BR:SP', 108 | type: 'state' 109 | }, 110 | { 111 | code: 'BR:RJ', 112 | type: 'state' 113 | } 114 | ]; 115 | 116 | WooCommerce.put("shipping/zones/5/locations", data) 117 | .then((response) => { 118 | console.log(response.data); 119 | }) 120 | .catch((error) => { 121 | console.log(error.response.data); 122 | }); 123 | ``` 124 | 125 | ```php 126 | 'BR:SP', 130 | 'type' => 'state' 131 | ], 132 | [ 133 | 'code' => 'BR:RJ', 134 | 'type' => 'state' 135 | ] 136 | ]; 137 | 138 | print_r($woocommerce->put('shipping/zones/5/locations', $data)); 139 | ?> 140 | ``` 141 | 142 | ```python 143 | data = [ 144 | { 145 | "code": "BR:SP", 146 | "type": "state" 147 | }, 148 | { 149 | "code": "BR:RJ", 150 | "type": "state" 151 | } 152 | ] 153 | 154 | print(wcapi.put("shipping/zones/5/locations", data).json()) 155 | ``` 156 | 157 | ```ruby 158 | data = [ 159 | { 160 | code: "BR:SP", 161 | type: "state" 162 | }, 163 | { 164 | code: "BR:RJ", 165 | type: "state" 166 | } 167 | ] 168 | 169 | woocommerce.put("shipping/zones/5/locations", data).parsed_response 170 | ``` 171 | 172 | > JSON response example: 173 | 174 | ```json 175 | [ 176 | { 177 | "code": "BR:SP", 178 | "type": "state", 179 | "_links": { 180 | "collection": [ 181 | { 182 | "href": "https://example.com/wp-json/wc/v2/shipping/zones/5/locations" 183 | } 184 | ], 185 | "describes": [ 186 | { 187 | "href": "https://example.com/wp-json/wc/v2/shipping/zones/5" 188 | } 189 | ] 190 | } 191 | }, 192 | { 193 | "code": "BR:RJ", 194 | "type": "state", 195 | "_links": { 196 | "collection": [ 197 | { 198 | "href": "https://example.com/wp-json/wc/v2/shipping/zones/5/locations" 199 | } 200 | ], 201 | "describes": [ 202 | { 203 | "href": "https://example.com/wp-json/wc/v2/shipping/zones/5" 204 | } 205 | ] 206 | } 207 | } 208 | ] 209 | ``` 210 | -------------------------------------------------------------------------------- /source/includes/wp-api-v2/_tax-classes.md: -------------------------------------------------------------------------------- 1 | # Tax classes # 2 | 3 | The tax classes API allows you to create, view, and delete individual tax classes. 4 | 5 | ## Tax class properties ## 6 | 7 | | Attribute | Type | Description | 8 | |-----------|--------|-------------------------------------------------------------------------------| 9 | | `slug` | string | Unique identifier for the resource. read-only | 10 | | `name` | string | Tax class name. required | 11 | 12 | ## Create a tax class ## 13 | 14 | This API helps you to create a new tax class. 15 | 16 | ### HTTP request ### 17 | 18 |
19 |
20 | POST 21 |
/wp-json/wc/v2/taxes/classes
22 |
23 |
24 | 25 | ```shell 26 | curl -X POST https://example.com/wp-json/wc/v2/taxes/classes \ 27 | -u consumer_key:consumer_secret \ 28 | -H "Content-Type: application/json" \ 29 | -d '{ 30 | "name": "Zero Rate" 31 | }' 32 | ``` 33 | 34 | ```javascript 35 | const data = { 36 | name: "Zero Rate" 37 | }; 38 | 39 | WooCommerce.post("taxes/classes", data) 40 | .then((response) => { 41 | console.log(response.data); 42 | }) 43 | .catch((error) => { 44 | console.log(error.response.data); 45 | }); 46 | ``` 47 | 48 | ```php 49 | 'Zero Rate' 52 | ]; 53 | 54 | print_r($woocommerce->post('taxes/classes', $data)); 55 | ?> 56 | ``` 57 | 58 | ```python 59 | data = { 60 | "name": "Zero Rate" 61 | } 62 | 63 | print(wcapi.post("taxes/classes", data).json()) 64 | ``` 65 | 66 | ```ruby 67 | data = { 68 | name: "Zero Rate" 69 | } 70 | 71 | woocommerce.post("taxes/classes", data).parsed_response 72 | ``` 73 | 74 | > JSON response example: 75 | 76 | ```json 77 | { 78 | "slug": "zero-rate", 79 | "name": "Zero Rate", 80 | "_links": { 81 | "collection": [ 82 | { 83 | "href": "https://example.com/wp-json/wc/v2/taxes/classes" 84 | } 85 | ] 86 | } 87 | } 88 | ``` 89 | 90 | ## List all tax classes ## 91 | 92 | This API helps you to view all tax classes. 93 | 94 | ### HTTP request ### 95 | 96 |
97 |
98 | GET 99 |
/wp-json/wc/v2/taxes/classes
100 |
101 |
102 | 103 | ```shell 104 | curl https://example.com/wp-json/wc/v2/taxes/classes \ 105 | -u consumer_key:consumer_secret 106 | ``` 107 | 108 | ```javascript 109 | WooCommerce.get("taxes/classes") 110 | .then((response) => { 111 | console.log(response.data); 112 | }) 113 | .catch((error) => { 114 | console.log(error.response.data); 115 | }); 116 | ``` 117 | 118 | ```php 119 | get('taxes/classes')); ?> 120 | ``` 121 | 122 | ```python 123 | print(wcapi.get("taxes/classes").json()) 124 | ``` 125 | 126 | ```ruby 127 | woocommerce.get("taxes/classes").parsed_response 128 | ``` 129 | 130 | > JSON response example: 131 | 132 | ```json 133 | [ 134 | { 135 | "slug": "standard", 136 | "name": "Standard Rate", 137 | "_links": { 138 | "collection": [ 139 | { 140 | "href": "https://example.com/wp-json/wc/v2/taxes/classes" 141 | } 142 | ] 143 | } 144 | }, 145 | { 146 | "slug": "reduced-rate", 147 | "name": "Reduced Rate", 148 | "_links": { 149 | "collection": [ 150 | { 151 | "href": "https://example.com/wp-json/wc/v2/taxes/classes" 152 | } 153 | ] 154 | } 155 | }, 156 | { 157 | "slug": "zero-rate", 158 | "name": "Zero Rate", 159 | "_links": { 160 | "collection": [ 161 | { 162 | "href": "https://example.com/wp-json/wc/v2/taxes/classes" 163 | } 164 | ] 165 | } 166 | } 167 | ] 168 | ``` 169 | 170 | ## Delete a tax class ## 171 | 172 | This API helps you delete a tax class. 173 | 174 | 177 | 178 | ### HTTP request ### 179 | 180 |
181 |
182 | DELETE 183 |
/wp-json/wc/v2/taxes/classes/<slug>
184 |
185 |
186 | 187 | ```shell 188 | curl -X DELETE https://example.com/wp-json/wc/v2/taxes/classes/zero-rate?force=true \ 189 | -u consumer_key:consumer_secret 190 | ``` 191 | 192 | ```javascript 193 | WooCommerce.delete("taxes/classes/zero-rate", { 194 | force: true 195 | }) 196 | .then((response) => { 197 | console.log(response.data); 198 | }) 199 | .catch((error) => { 200 | console.log(error.response.data); 201 | }); 202 | ``` 203 | 204 | ```php 205 | delete('taxes/classes/zero-rate', ['force' => true])); ?> 206 | ``` 207 | 208 | ```python 209 | print(wcapi.delete("taxes/classes/zero-rate", params={"force": True}).json()) 210 | ``` 211 | 212 | ```ruby 213 | woocommerce.delete("taxes/classes/zero-rate", force: true).parsed_response 214 | ``` 215 | 216 | > JSON response example: 217 | 218 | ```json 219 | { 220 | "slug": "zero-rate", 221 | "name": "Zero Rate", 222 | "_links": { 223 | "collection": [ 224 | { 225 | "href": "https://example.com/wp-json/wc/v2/taxes/classes" 226 | } 227 | ] 228 | } 229 | } 230 | ``` 231 | 232 | #### Available parameters #### 233 | 234 | | Parameter | Type | Description | 235 | |-----------|--------|---------------------------------------------------------------| 236 | | `force` | string | Required to be `true`, since this resource does not support trashing. | 237 | -------------------------------------------------------------------------------- /source/includes/wp-api-v3/_order-actions.md: -------------------------------------------------------------------------------- 1 | # Order actions # 2 | 3 | The order actions API allows you to perform specific actions with existing orders like you can from the Edit Order screen in the web app. 4 | 5 | _Note: currently only one action is available, other actions will be introduced at a later time._ 6 | 7 | ## Send order details to customer ## 8 | 9 | This endpoint allows you to trigger an email to the customer with the details of their order, if the order contains a customer email address. 10 | 11 | ### HTTP request ### 12 | 13 |
14 |
15 | POST 16 |
/wp-json/wc/v3/orders/<id>/actions/send_order_details
17 |
18 |
19 | 20 | ```shell 21 | curl -X POST https://example.com/wp-json/wc/v3/orders/723/actions/send_order_details \ 22 | -u consumer_key:consumer_secret 23 | ``` 24 | 25 | ```javascript 26 | WooCommerce.post("orders/723/actions/send_order_details") 27 | .then((response) => { 28 | console.log(response.data); 29 | }) 30 | .catch((error) => { 31 | console.log(error.response.data); 32 | }); 33 | ``` 34 | 35 | ```php 36 | post('orders/723/actions/send_order_details')); 38 | ?> 39 | ``` 40 | 41 | ```python 42 | print(wcapi.post("orders/723/actions/send_order_details").json()) 43 | ``` 44 | 45 | ```ruby 46 | woocommerce.post("orders/723/actions/send_order_details").parsed_response 47 | ``` 48 | 49 | > JSON response examples: 50 | 51 | ```json 52 | { 53 | "message": "Order details sent to woo@example.com, via REST API." 54 | } 55 | ``` 56 | 57 | ```json 58 | { 59 | "code": "woocommerce_rest_missing_email", 60 | "message": "Order does not have an email address.", 61 | "data": { 62 | "status": 400 63 | } 64 | } 65 | ``` 66 | -------------------------------------------------------------------------------- /source/includes/wp-api-v3/_product-custom-fields.md: -------------------------------------------------------------------------------- 1 | # Product custom fields # 2 | 3 | The product custom fields API allows you to view the custom field names that have been recorded. 4 | 5 | ## Custom fields available parameters ## 6 | 7 | | Parameter | Type | Description | 8 | | ---------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- | 9 | | `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. Default is `view`. | 10 | | `page` | integer | Current page of the collection. Default is `1`. | 11 | | `per_page` | integer | Maximum number of items to be returned in result set. Default is `10`. | 12 | | `search` | string | Limit results to those matching a string. | 13 | | `order` | string | Order sort attribute ascending or descending. Options: `asc` and `desc`. Default is `desc`. | 14 | 15 | ## Retrieve product custom field names ## 16 | 17 | This API lets you retrieve filtered custom field names. 18 | 19 |
20 |
21 | GET 22 |
/wp-json/wc/v3/products/custom-fields/names
23 |
24 |
25 | 26 | ```shell 27 | curl https://example.com/wp-json/wc/v3/products/custom-fields/names \ 28 | -u consumer_key:consumer_secret 29 | ``` 30 | 31 | ```javascript 32 | WooCommerce.get("products/custom-fields/names") 33 | .then((response) => { 34 | console.log(response.data); 35 | }) 36 | .catch((error) => { 37 | console.log(error.response.data); 38 | }); 39 | ``` 40 | 41 | ```php 42 | get('products/custom-fields/names')); ?> 43 | ``` 44 | 45 | ```python 46 | print(wcapi.get("products/custom-fields/names").json()) 47 | ``` 48 | 49 | ```ruby 50 | woocommerce.get("products/custom-fields/names").parsed_response 51 | ``` 52 | 53 | > JSON response example: 54 | 55 | ```json 56 | { 57 | [ 58 | "Custom field 1", 59 | "Custom field 2", 60 | "Custom field 3", 61 | "Custom field 4" 62 | ] 63 | } 64 | ``` 65 | -------------------------------------------------------------------------------- /source/includes/wp-api-v3/_refunds.md: -------------------------------------------------------------------------------- 1 | # Refunds # 2 | 3 | The refunds API is a simple, read-only endpoint that allows you to retrieve a list of refunds outside the context of an existing order. To create, view, and delete individual refunds, check out the [order refunds API](#order-refunds). 4 | 5 | ## Refund properties ## 6 | 7 | All properties are the same as those in the [order refunds endpoint](#order-refund-properties), but with one additional property: 8 | 9 | | Attribute | Type | Description | 10 | |-------------|---------|----------------------------------------------------| 11 | | `parent_id` | integer | The ID of the order the refund is associated with. | 12 | 13 | ## Retrieve a list of refunds ## 14 | 15 | This API lets you retrieve and view refunds from your store, regardless of which order they are associated with. 16 | 17 | ### HTTP request ### 18 | 19 |
20 |
21 | GET 22 |
/wp-json/wc/v3/refunds
23 |
24 |
25 | 26 | ```shell 27 | curl https://example.com/wp-json/wc/v3/refunds \ 28 | -u consumer_key:consumer_secret 29 | ``` 30 | 31 | ```javascript 32 | WooCommerce.get("refunds") 33 | .then((response) => { 34 | console.log(response.data); 35 | }) 36 | .catch((error) => { 37 | console.log(error.response.data); 38 | }); 39 | ``` 40 | 41 | ```php 42 | get('refunds')); ?> 43 | ``` 44 | 45 | ```python 46 | print(wcapi.get("refunds").json()) 47 | ``` 48 | 49 | ```ruby 50 | woocommerce.get("refunds").parsed_response 51 | ``` 52 | 53 | > JSON response example: 54 | 55 | ```json 56 | [ 57 | { 58 | "id": 726, 59 | "parent_id": 124, 60 | "date_created": "2017-03-21T17:07:11", 61 | "date_created_gmt": "2017-03-21T20:07:11", 62 | "amount": "10.00", 63 | "reason": "", 64 | "refunded_by": 1, 65 | "refunded_payment": false, 66 | "meta_data": [], 67 | "line_items": [], 68 | "_links": { 69 | "self": [ 70 | { 71 | "href": "https://example.com/wp-json/wc/v3/orders/723/refunds/726" 72 | } 73 | ], 74 | "collection": [ 75 | { 76 | "href": "https://example.com/wp-json/wc/v3/orders/723/refunds" 77 | } 78 | ], 79 | "up": [ 80 | { 81 | "href": "https://example.com/wp-json/wc/v3/orders/723" 82 | } 83 | ] 84 | } 85 | }, 86 | { 87 | "id": 724, 88 | "parent_id": 63, 89 | "date_created": "2017-03-21T16:55:37", 90 | "date_created_gmt": "2017-03-21T19:55:37", 91 | "amount": "9.00", 92 | "reason": "", 93 | "refunded_by": 1, 94 | "refunded_payment": false, 95 | "meta_data": [], 96 | "line_items": [ 97 | { 98 | "id": 314, 99 | "name": "Woo Album #2", 100 | "product_id": 87, 101 | "variation_id": 0, 102 | "quantity": -1, 103 | "tax_class": "", 104 | "subtotal": "-9.00", 105 | "subtotal_tax": "0.00", 106 | "total": "-9.00", 107 | "total_tax": "0.00", 108 | "taxes": [], 109 | "meta_data": [ 110 | { 111 | "id": 2076, 112 | "key": "_refunded_item_id", 113 | "value": "311" 114 | } 115 | ], 116 | "sku": "", 117 | "price": -9 118 | } 119 | ], 120 | "_links": { 121 | "self": [ 122 | { 123 | "href": "https://example.com/wp-json/wc/v3/orders/723/refunds/724" 124 | } 125 | ], 126 | "collection": [ 127 | { 128 | "href": "https://example.com/wp-json/wc/v3/orders/723/refunds" 129 | } 130 | ], 131 | "up": [ 132 | { 133 | "href": "https://example.com/wp-json/wc/v3/orders/723" 134 | } 135 | ] 136 | } 137 | } 138 | ] 139 | ``` 140 | 141 | #### Available parameters #### 142 | 143 | | Parameter | Type | Description | 144 | |------------------|---------|------------------------------------------------------------------------------------------------------------------------------| 145 | | `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. Default is `view`. | 146 | | `page` | integer | Current page of the collection. Default is `1`. | 147 | | `per_page` | integer | Maximum number of items to be returned in result set. Default is `10`. | 148 | | `search` | string | Limit results to those matching a string. | 149 | | `after` | string | Limit response to resources published after a given ISO8601 compliant date. | 150 | | `before` | string | Limit response to resources published before a given ISO8601 compliant date. | 151 | | `exclude` | array | Ensure result set excludes specific IDs. | 152 | | `include` | array | Limit result set to specific ids. | 153 | | `offset` | integer | Offset the result set by a specific number of items. | 154 | | `order` | string | Order sort attribute ascending or descending. Options: `asc` and `desc`. Default is `desc`. | 155 | | `orderby` | string | Sort collection by object attribute. Options: `date`, `modified`, `id`, `include`, `title` and `slug`. Default is `date`. | 156 | | `parent` | array | Limit result set to those of particular parent IDs. | 157 | | `parent_exclude` | array | Limit result set to all items except those of a particular parent ID. | 158 | | `dp` | integer | Number of decimal points to use in each resource. Default is `2`. | 159 | -------------------------------------------------------------------------------- /source/includes/wp-api-v3/_shipping-methods.md: -------------------------------------------------------------------------------- 1 | # Shipping methods # 2 | 3 | The shipping methods API allows you to view individual shipping methods. 4 | 5 | ## Shipping method properties ## 6 | 7 | | Attribute | Type | Description | 8 | | ------------- | ------ | ---------------------------------------------------------------------- | 9 | | `id` | string | Method ID. read-only | 10 | | `title` | string | Shipping method title. read-only | 11 | | `description` | string | Shipping method description. read-only | 12 | 13 | ## Retrieve a shipping method ## 14 | 15 | This API lets you retrieve and view a specific shipping method. 16 | 17 | ### HTTP request ### 18 | 19 |
20 |
21 | GET 22 |
/wp-json/wc/v3/shipping_methods/<id>
23 |
24 |
25 | 26 | ```shell 27 | curl https://example.com/wp-json/wc/v3/shipping_methods/flat_rate \ 28 | -u consumer_key:consumer_secret 29 | ``` 30 | 31 | ```javascript 32 | WooCommerce.get("shipping_methods/flat_rate") 33 | .then((response) => { 34 | console.log(response.data); 35 | }) 36 | .catch((error) => { 37 | console.log(error.response.data); 38 | }); 39 | ``` 40 | 41 | ```php 42 | get('shipping_methods/flat_rate')); ?> 43 | ``` 44 | 45 | ```python 46 | print(wcapi.get("shipping_methods/flat_rate").json()) 47 | ``` 48 | 49 | ```ruby 50 | woocommerce.get("shipping_methods/flat_rate").parsed_response 51 | ``` 52 | 53 | > JSON response example: 54 | 55 | ```json 56 | { 57 | "id": "flat_rate", 58 | "title": "Flat rate", 59 | "description": "Lets you charge a fixed rate for shipping.", 60 | "_links": { 61 | "self": [ 62 | { 63 | "href": "https://example.com/wp-json/wc/v3/shipping_methods/flat_rate" 64 | } 65 | ], 66 | "collection": [ 67 | { 68 | "href": "https://example.com/wp-json/wc/v3/shipping_methods" 69 | } 70 | ] 71 | } 72 | } 73 | ``` 74 | 75 | ## List all shipping methods ## 76 | 77 | This API helps you to view all the shipping methods. 78 | 79 | ### HTTP request ### 80 | 81 |
82 |
83 | GET 84 |
/wp-json/wc/v3/shipping_methods
85 |
86 |
87 | 88 | ```shell 89 | curl https://example.com/wp-json/wc/v3/shipping_methods \ 90 | -u consumer_key:consumer_secret 91 | ``` 92 | 93 | ```javascript 94 | WooCommerce.get("shipping_methods") 95 | .then((response) => { 96 | console.log(response.data); 97 | }) 98 | .catch((error) => { 99 | console.log(error.response.data); 100 | }); 101 | ``` 102 | 103 | ```php 104 | get('shipping_methods')); ?> 105 | ``` 106 | 107 | ```python 108 | print(wcapi.get("shipping_methods").json()) 109 | ``` 110 | 111 | ```ruby 112 | woocommerce.get("shipping_methods").parsed_response 113 | ``` 114 | 115 | > JSON response example: 116 | 117 | ```json 118 | [ 119 | { 120 | "id": "flat_rate", 121 | "title": "Flat rate", 122 | "description": "Lets you charge a fixed rate for shipping.", 123 | "_links": { 124 | "self": [ 125 | { 126 | "href": "https://example.com/wp-json/wc/v3/shipping_methods/flat_rate" 127 | } 128 | ], 129 | "collection": [ 130 | { 131 | "href": "https://example.com/wp-json/wc/v3/shipping_methods" 132 | } 133 | ] 134 | } 135 | }, 136 | { 137 | "id": "free_shipping", 138 | "title": "Free shipping", 139 | "description": "Free shipping is a special method which can be triggered with coupons and minimum spends.", 140 | "_links": { 141 | "self": [ 142 | { 143 | "href": "https://example.com/wp-json/wc/v3/shipping_methods/free_shipping" 144 | } 145 | ], 146 | "collection": [ 147 | { 148 | "href": "https://example.com/wp-json/wc/v3/shipping_methods" 149 | } 150 | ] 151 | } 152 | }, 153 | { 154 | "id": "local_pickup", 155 | "title": "Local pickup", 156 | "description": "Allow customers to pick up orders themselves. By default, when using local pickup store base taxes will apply regardless of customer address.", 157 | "_links": { 158 | "self": [ 159 | { 160 | "href": "https://example.com/wp-json/wc/v3/shipping_methods/local_pickup" 161 | } 162 | ], 163 | "collection": [ 164 | { 165 | "href": "https://example.com/wp-json/wc/v3/shipping_methods" 166 | } 167 | ] 168 | } 169 | } 170 | ] 171 | ``` 172 | -------------------------------------------------------------------------------- /source/includes/wp-api-v3/_shipping-zone-locations.md: -------------------------------------------------------------------------------- 1 | # Shipping zone locations # 2 | 3 | The shipping zone locations API allows you to view and batch update locations of a shipping zone. 4 | 5 | ## Shipping location properties ## 6 | 7 | | Attribute | Type | Description | 8 | | --------- | ------ | ----------------------------------------------------------------------------------------------------------- | 9 | | `code` | string | Shipping zone location code. | 10 | | `type` | string | Shipping zone location type. Options: `postcode`, `state`, `country` and `continent`. Default is `country`. | 11 | 12 | ## List all locations of a shipping zone ## 13 | 14 | This API helps you to view all the locations of a shipping zone. 15 | 16 | ### HTTP request ### 17 | 18 |
19 |
20 | GET 21 |
/wp-json/wc/v3/shipping/zones/<id>/locations
22 |
23 |
24 | 25 | ```shell 26 | curl https://example.com/wp-json/wc/v3/shipping/zones/5/locations \ 27 | -u consumer_key:consumer_secret 28 | ``` 29 | 30 | ```javascript 31 | WooCommerce.get("shipping/zones/5/locations") 32 | .then((response) => { 33 | console.log(response.data); 34 | }) 35 | .catch((error) => { 36 | console.log(error.response.data); 37 | }); 38 | ``` 39 | 40 | ```php 41 | get('shipping/zones/5/locations')); ?> 42 | ``` 43 | 44 | ```python 45 | print(wcapi.get("shipping/zones/5/locations").json()) 46 | ``` 47 | 48 | ```ruby 49 | woocommerce.get("shipping/zones/5/locations").parsed_response 50 | ``` 51 | 52 | > JSON response example: 53 | 54 | ```json 55 | [ 56 | { 57 | "code": "BR", 58 | "type": "country", 59 | "_links": { 60 | "collection": [ 61 | { 62 | "href": "https://example.com/wp-json/wc/v3/shipping/zones/5/locations" 63 | } 64 | ], 65 | "describes": [ 66 | { 67 | "href": "https://example.com/wp-json/wc/v3/shipping/zones/5" 68 | } 69 | ] 70 | } 71 | } 72 | ] 73 | ``` 74 | 75 | ## Update a locations of a shipping zone ## 76 | 77 | This API lets you make changes to locations of a shipping zone. 78 | 79 | ### HTTP request ### 80 | 81 |
82 |
83 | PUT 84 |
/wp-json/wc/v3/shipping/zones/<id>/locations
85 |
86 |
87 | 88 | ```shell 89 | curl -X PUT https://example.com/wp-json/wc/v3/shipping/zones/5/locations \ 90 | -u consumer_key:consumer_secret \ 91 | -H "Content-Type: application/json" \ 92 | -d '[ 93 | { 94 | "code": "BR:SP", 95 | "type": "state" 96 | }, 97 | { 98 | "code": "BR:RJ", 99 | "type": "state" 100 | } 101 | ]' 102 | ``` 103 | 104 | ```javascript 105 | var data = [ 106 | { 107 | code: 'BR:SP', 108 | type: 'state' 109 | }, 110 | { 111 | code: 'BR:RJ', 112 | type: 'state' 113 | } 114 | ]; 115 | 116 | WooCommerce.put("shipping/zones/5/locations", data) 117 | .then((response) => { 118 | console.log(response.data); 119 | }) 120 | .catch((error) => { 121 | console.log(error.response.data); 122 | }); 123 | ``` 124 | 125 | ```php 126 | 'BR:SP', 130 | 'type' => 'state' 131 | ], 132 | [ 133 | 'code' => 'BR:RJ', 134 | 'type' => 'state' 135 | ] 136 | ]; 137 | 138 | print_r($woocommerce->put('shipping/zones/5/locations', $data)); 139 | ?> 140 | ``` 141 | 142 | ```python 143 | data = [ 144 | { 145 | "code": "BR:SP", 146 | "type": "state" 147 | }, 148 | { 149 | "code": "BR:RJ", 150 | "type": "state" 151 | } 152 | ] 153 | 154 | print(wcapi.put("shipping/zones/5/locations", data).json()) 155 | ``` 156 | 157 | ```ruby 158 | data = [ 159 | { 160 | code: "BR:SP", 161 | type: "state" 162 | }, 163 | { 164 | code: "BR:RJ", 165 | type: "state" 166 | } 167 | ] 168 | 169 | woocommerce.put("shipping/zones/5/locations", data).parsed_response 170 | ``` 171 | 172 | > JSON response example: 173 | 174 | ```json 175 | [ 176 | { 177 | "code": "BR:SP", 178 | "type": "state", 179 | "_links": { 180 | "collection": [ 181 | { 182 | "href": "https://example.com/wp-json/wc/v3/shipping/zones/5/locations" 183 | } 184 | ], 185 | "describes": [ 186 | { 187 | "href": "https://example.com/wp-json/wc/v3/shipping/zones/5" 188 | } 189 | ] 190 | } 191 | }, 192 | { 193 | "code": "BR:RJ", 194 | "type": "state", 195 | "_links": { 196 | "collection": [ 197 | { 198 | "href": "https://example.com/wp-json/wc/v3/shipping/zones/5/locations" 199 | } 200 | ], 201 | "describes": [ 202 | { 203 | "href": "https://example.com/wp-json/wc/v3/shipping/zones/5" 204 | } 205 | ] 206 | } 207 | } 208 | ] 209 | ``` 210 | -------------------------------------------------------------------------------- /source/includes/wp-api-v3/_tax-classes.md: -------------------------------------------------------------------------------- 1 | # Tax classes # 2 | 3 | The tax classes API allows you to create, view, and delete individual tax classes. 4 | 5 | ## Tax class properties ## 6 | 7 | | Attribute | Type | Description | 8 | |-----------|--------|-------------------------------------------------------------------------------| 9 | | `slug` | string | Unique identifier for the resource. read-only | 10 | | `name` | string | Tax class name. required | 11 | 12 | ## Create a tax class ## 13 | 14 | This API helps you to create a new tax class. 15 | 16 | ### HTTP request ### 17 | 18 |
19 |
20 | POST 21 |
/wp-json/wc/v3/taxes/classes
22 |
23 |
24 | 25 | ```shell 26 | curl -X POST https://example.com/wp-json/wc/v3/taxes/classes \ 27 | -u consumer_key:consumer_secret \ 28 | -H "Content-Type: application/json" \ 29 | -d '{ 30 | "name": "Zero Rate" 31 | }' 32 | ``` 33 | 34 | ```javascript 35 | const data = { 36 | name: "Zero Rate" 37 | }; 38 | 39 | WooCommerce.post("taxes/classes", data) 40 | .then((response) => { 41 | console.log(response.data); 42 | }) 43 | .catch((error) => { 44 | console.log(error.response.data); 45 | }); 46 | ``` 47 | 48 | ```php 49 | 'Zero Rate' 52 | ]; 53 | 54 | print_r($woocommerce->post('taxes/classes', $data)); 55 | ?> 56 | ``` 57 | 58 | ```python 59 | data = { 60 | "name": "Zero Rate" 61 | } 62 | 63 | print(wcapi.post("taxes/classes", data).json()) 64 | ``` 65 | 66 | ```ruby 67 | data = { 68 | name: "Zero Rate" 69 | } 70 | 71 | woocommerce.post("taxes/classes", data).parsed_response 72 | ``` 73 | 74 | > JSON response example: 75 | 76 | ```json 77 | { 78 | "slug": "zero-rate", 79 | "name": "Zero Rate", 80 | "_links": { 81 | "collection": [ 82 | { 83 | "href": "https://example.com/wp-json/wc/v3/taxes/classes" 84 | } 85 | ] 86 | } 87 | } 88 | ``` 89 | 90 | ## List all tax classes ## 91 | 92 | This API helps you to view all tax classes. 93 | 94 | ### HTTP request ### 95 | 96 |
97 |
98 | GET 99 |
/wp-json/wc/v3/taxes/classes
100 |
101 |
102 | 103 | ```shell 104 | curl https://example.com/wp-json/wc/v3/taxes/classes \ 105 | -u consumer_key:consumer_secret 106 | ``` 107 | 108 | ```javascript 109 | WooCommerce.get("taxes/classes") 110 | .then((response) => { 111 | console.log(response.data); 112 | }) 113 | .catch((error) => { 114 | console.log(error.response.data); 115 | }); 116 | ``` 117 | 118 | ```php 119 | get('taxes/classes')); ?> 120 | ``` 121 | 122 | ```python 123 | print(wcapi.get("taxes/classes").json()) 124 | ``` 125 | 126 | ```ruby 127 | woocommerce.get("taxes/classes").parsed_response 128 | ``` 129 | 130 | > JSON response example: 131 | 132 | ```json 133 | [ 134 | { 135 | "slug": "standard", 136 | "name": "Standard Rate", 137 | "_links": { 138 | "collection": [ 139 | { 140 | "href": "https://example.com/wp-json/wc/v3/taxes/classes" 141 | } 142 | ] 143 | } 144 | }, 145 | { 146 | "slug": "reduced-rate", 147 | "name": "Reduced Rate", 148 | "_links": { 149 | "collection": [ 150 | { 151 | "href": "https://example.com/wp-json/wc/v3/taxes/classes" 152 | } 153 | ] 154 | } 155 | }, 156 | { 157 | "slug": "zero-rate", 158 | "name": "Zero Rate", 159 | "_links": { 160 | "collection": [ 161 | { 162 | "href": "https://example.com/wp-json/wc/v3/taxes/classes" 163 | } 164 | ] 165 | } 166 | } 167 | ] 168 | ``` 169 | 170 | ## Delete a tax class ## 171 | 172 | This API helps you delete a tax class. 173 | 174 | 177 | 178 | ### HTTP request ### 179 | 180 |
181 |
182 | DELETE 183 |
/wp-json/wc/v3/taxes/classes/<slug>
184 |
185 |
186 | 187 | ```shell 188 | curl -X DELETE https://example.com/wp-json/wc/v3/taxes/classes/zero-rate?force=true \ 189 | -u consumer_key:consumer_secret 190 | ``` 191 | 192 | ```javascript 193 | WooCommerce.delete("taxes/classes/zero-rate", { 194 | force: true 195 | }) 196 | .then((response) => { 197 | console.log(response.data); 198 | }) 199 | .catch((error) => { 200 | console.log(error.response.data); 201 | }); 202 | ``` 203 | 204 | ```php 205 | delete('taxes/classes/zero-rate', ['force' => true])); ?> 206 | ``` 207 | 208 | ```python 209 | print(wcapi.delete("taxes/classes/zero-rate", params={"force": True}).json()) 210 | ``` 211 | 212 | ```ruby 213 | woocommerce.delete("taxes/classes/zero-rate", force: true).parsed_response 214 | ``` 215 | 216 | > JSON response example: 217 | 218 | ```json 219 | { 220 | "slug": "zero-rate", 221 | "name": "Zero Rate", 222 | "_links": { 223 | "collection": [ 224 | { 225 | "href": "https://example.com/wp-json/wc/v3/taxes/classes" 226 | } 227 | ] 228 | } 229 | } 230 | ``` 231 | 232 | #### Available parameters #### 233 | 234 | | Parameter | Type | Description | 235 | |-----------|--------|---------------------------------------------------------------| 236 | | `force` | string | Required to be `true`, since this resource does not support trashing. | 237 | -------------------------------------------------------------------------------- /source/index.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: WooCommerce REST API Documentation - WP REST API v3 3 | 4 | language_tabs: 5 | - shell: cURL 6 | - javascript: Node.js 7 | - php: PHP 8 | - python: Python 9 | - ruby: Ruby 10 | 11 | toc_footers: 12 | - We're hiring! 13 | - Contributing to WC REST API Docs 14 | - REST API Source on GitHub 15 | - REST API Issues 16 | - WooCommerce Documentation 17 | - WooCommerce Repository 18 | - Documentation Powered by Slate 19 | 20 | includes: 21 | - wp-api-v3/introduction 22 | - wp-api-v3/authentication 23 | - wp-api-v3/index 24 | - wp-api-v3/coupons 25 | - wp-api-v3/customers 26 | - wp-api-v3/orders 27 | - wp-api-v3/order-actions 28 | - wp-api-v3/order-notes 29 | - wp-api-v3/order-refunds 30 | - wp-api-v3/products 31 | - wp-api-v3/product-variations 32 | - wp-api-v3/product-attributes 33 | - wp-api-v3/product-attribute-terms 34 | - wp-api-v3/product-categories 35 | - wp-api-v3/product-custom-fields 36 | - wp-api-v3/product-shipping-classes 37 | - wp-api-v3/product-tags 38 | - wp-api-v3/product-reviews 39 | - wp-api-v3/reports 40 | - wp-api-v3/refunds 41 | - wp-api-v3/taxes 42 | - wp-api-v3/tax-classes 43 | - wp-api-v3/webhooks 44 | - wp-api-v3/settings 45 | - wp-api-v3/setting-options 46 | - wp-api-v3/payment-gateways 47 | - wp-api-v3/shipping-zones 48 | - wp-api-v3/shipping-zone-locations 49 | - wp-api-v3/shipping-zone-methods 50 | - wp-api-v3/shipping-methods 51 | - wp-api-v3/system-status 52 | - wp-api-v3/system-status-tools 53 | - wp-api-v3/data 54 | 55 | search: false 56 | --- 57 | -------------------------------------------------------------------------------- /source/javascripts/all.js: -------------------------------------------------------------------------------- 1 | //= require ./all_nosearch 2 | //= require ./app/_search 3 | -------------------------------------------------------------------------------- /source/javascripts/all_nosearch.js: -------------------------------------------------------------------------------- 1 | //= require ./lib/_energize 2 | //= require ./app/_toc 3 | //= require ./app/_lang 4 | 5 | $(function() { 6 | loadToc($('#toc'), '.toc-link', '.toc-list-h2', 10); 7 | setupLanguages($('body').data('languages')); 8 | $('.content').imagesLoaded( function() { 9 | window.recacheHeights(); 10 | window.refreshToc(); 11 | }); 12 | }); 13 | 14 | window.onpopstate = function() { 15 | activateLanguage(getLanguageFromQueryString()); 16 | }; 17 | -------------------------------------------------------------------------------- /source/javascripts/app/_lang.js: -------------------------------------------------------------------------------- 1 | //= require ../lib/_jquery 2 | 3 | /* 4 | Copyright 2008-2013 Concur Technologies, Inc. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); you may 7 | not use this file except in compliance with the License. You may obtain 8 | a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 14 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 15 | License for the specific language governing permissions and limitations 16 | under the License. 17 | */ 18 | ;(function () { 19 | 'use strict'; 20 | 21 | var languages = []; 22 | 23 | window.setupLanguages = setupLanguages; 24 | window.activateLanguage = activateLanguage; 25 | window.getLanguageFromQueryString = getLanguageFromQueryString; 26 | 27 | function activateLanguage(language) { 28 | if (!language) return; 29 | if (language === "") return; 30 | 31 | $(".lang-selector a").removeClass('active'); 32 | $(".lang-selector a[data-language-name='" + language + "']").addClass('active'); 33 | for (var i=0; i < languages.length; i++) { 34 | $(".highlight.tab-" + languages[i]).hide(); 35 | $(".lang-specific." + languages[i]).hide(); 36 | } 37 | $(".highlight.tab-" + language).show(); 38 | $(".lang-specific." + language).show(); 39 | 40 | window.recacheHeights(); 41 | 42 | // scroll to the new location of the position 43 | if ($(window.location.hash).get(0)) { 44 | $(window.location.hash).get(0).scrollIntoView(true); 45 | } 46 | } 47 | 48 | // parseURL and stringifyURL are from https://github.com/sindresorhus/query-string 49 | // MIT licensed 50 | // https://github.com/sindresorhus/query-string/blob/7bee64c16f2da1a326579e96977b9227bf6da9e6/license 51 | function parseURL(str) { 52 | if (typeof str !== 'string') { 53 | return {}; 54 | } 55 | 56 | str = str.trim().replace(/^(\?|#|&)/, ''); 57 | 58 | if (!str) { 59 | return {}; 60 | } 61 | 62 | return str.split('&').reduce(function (ret, param) { 63 | var parts = param.replace(/\+/g, ' ').split('='); 64 | var key = parts[0]; 65 | var val = parts[1]; 66 | 67 | key = decodeURIComponent(key); 68 | // missing `=` should be `null`: 69 | // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters 70 | val = val === undefined ? null : decodeURIComponent(val); 71 | 72 | if (!ret.hasOwnProperty(key)) { 73 | ret[key] = val; 74 | } else if (Array.isArray(ret[key])) { 75 | ret[key].push(val); 76 | } else { 77 | ret[key] = [ret[key], val]; 78 | } 79 | 80 | return ret; 81 | }, {}); 82 | }; 83 | 84 | function stringifyURL(obj) { 85 | return obj ? Object.keys(obj).sort().map(function (key) { 86 | var val = obj[key]; 87 | 88 | if (Array.isArray(val)) { 89 | return val.sort().map(function (val2) { 90 | return encodeURIComponent(key) + '=' + encodeURIComponent(val2); 91 | }).join('&'); 92 | } 93 | 94 | return encodeURIComponent(key) + '=' + encodeURIComponent(val); 95 | }).join('&') : ''; 96 | }; 97 | 98 | // gets the language set in the query string 99 | function getLanguageFromQueryString() { 100 | if (location.search.length >= 1) { 101 | var language = parseURL(location.search).language; 102 | if (language) { 103 | return language; 104 | } else if (jQuery.inArray(location.search.substr(1), languages) != -1) { 105 | return location.search.substr(1); 106 | } 107 | } 108 | 109 | return false; 110 | } 111 | 112 | // returns a new query string with the new language in it 113 | function generateNewQueryString(language) { 114 | var url = parseURL(location.search); 115 | if (url.language) { 116 | url.language = language; 117 | return stringifyURL(url); 118 | } 119 | return language; 120 | } 121 | 122 | // if a button is clicked, add the state to the history 123 | function pushURL(language) { 124 | if (!history) { return; } 125 | var hash = window.location.hash; 126 | if (hash) { 127 | hash = hash.replace(/^#+/, ''); 128 | } 129 | history.pushState({}, '', '?' + generateNewQueryString(language) + '#' + hash); 130 | 131 | // save language as next default 132 | localStorage.setItem("language", language); 133 | } 134 | 135 | function setupLanguages(l) { 136 | var defaultLanguage = localStorage.getItem("language"); 137 | 138 | languages = l; 139 | 140 | var presetLanguage = getLanguageFromQueryString(); 141 | if (presetLanguage) { 142 | // the language is in the URL, so use that language! 143 | activateLanguage(presetLanguage); 144 | 145 | localStorage.setItem("language", presetLanguage); 146 | } else if ((defaultLanguage !== null) && (jQuery.inArray(defaultLanguage, languages) != -1)) { 147 | // the language was the last selected one saved in localstorage, so use that language! 148 | activateLanguage(defaultLanguage); 149 | } else { 150 | // no language selected, so use the default 151 | activateLanguage(languages[0]); 152 | } 153 | } 154 | 155 | // if we click on a language tab, activate that language 156 | $(function() { 157 | $(".lang-selector a").on("click", function() { 158 | var language = $(this).data("language-name"); 159 | pushURL(language); 160 | activateLanguage(language); 161 | return false; 162 | }); 163 | }); 164 | })(); 165 | -------------------------------------------------------------------------------- /source/javascripts/app/_search.js: -------------------------------------------------------------------------------- 1 | //= require ../lib/_lunr 2 | //= require ../lib/_jquery 3 | //= require ../lib/_jquery.highlight 4 | ;(function () { 5 | 'use strict'; 6 | 7 | var content, searchResults; 8 | var highlightOpts = { element: 'span', className: 'search-highlight' }; 9 | var searchDelay = 0; 10 | var timeoutHandle = 0; 11 | 12 | var index = new lunr.Index(); 13 | 14 | index.ref('id'); 15 | index.field('title', { boost: 10 }); 16 | index.field('body'); 17 | index.pipeline.add(lunr.trimmer, lunr.stopWordFilter); 18 | 19 | $(populate); 20 | $(bind); 21 | 22 | function populate() { 23 | $('h1, h2').each(function() { 24 | var title = $(this); 25 | var body = title.nextUntil('h1, h2'); 26 | index.add({ 27 | id: title.prop('id'), 28 | title: title.text(), 29 | body: body.text() 30 | }); 31 | }); 32 | 33 | determineSearchDelay(); 34 | } 35 | function determineSearchDelay() { 36 | if(index.tokenStore.length>5000) { 37 | searchDelay = 300; 38 | } 39 | } 40 | 41 | function bind() { 42 | content = $('.content'); 43 | searchResults = $('.search-results'); 44 | 45 | $('#input-search').on('keyup',function(e) { 46 | var wait = function() { 47 | return function(executingFunction, waitTime){ 48 | clearTimeout(timeoutHandle); 49 | timeoutHandle = setTimeout(executingFunction, waitTime); 50 | }; 51 | }(); 52 | wait(function(){ 53 | search(e); 54 | }, searchDelay ); 55 | }); 56 | } 57 | 58 | function search(event) { 59 | 60 | var searchInput = $('#input-search')[0]; 61 | 62 | unhighlight(); 63 | searchResults.addClass('visible'); 64 | 65 | // ESC clears the field 66 | if (event.keyCode === 27) searchInput.value = ''; 67 | 68 | if (searchInput.value) { 69 | var results = index.search(searchInput.value).filter(function(r) { 70 | return r.score > 0.0001; 71 | }); 72 | 73 | if (results.length) { 74 | searchResults.empty(); 75 | $.each(results, function (index, result) { 76 | var elem = document.getElementById(result.ref); 77 | searchResults.append("
  • " + $(elem).text() + "
  • "); 78 | }); 79 | highlight.call(searchInput); 80 | } else { 81 | searchResults.html('
  • '); 82 | $('.search-results li').text('No Results Found for "' + searchInput.value + '"'); 83 | } 84 | } else { 85 | unhighlight(); 86 | searchResults.removeClass('visible'); 87 | } 88 | } 89 | 90 | function highlight() { 91 | if (this.value) content.highlight(this.value, highlightOpts); 92 | } 93 | 94 | function unhighlight() { 95 | content.unhighlight(highlightOpts); 96 | } 97 | })(); 98 | 99 | -------------------------------------------------------------------------------- /source/javascripts/app/_toc.js: -------------------------------------------------------------------------------- 1 | //= require ../lib/_jquery 2 | //= require ../lib/_imagesloaded.min 3 | ;(function () { 4 | 'use strict'; 5 | 6 | var htmlPattern = /<[^>]*>/g; 7 | var loaded = false; 8 | 9 | var debounce = function(func, waitTime) { 10 | var timeout = false; 11 | return function() { 12 | if (timeout === false) { 13 | setTimeout(function() { 14 | func(); 15 | timeout = false; 16 | }, waitTime); 17 | timeout = true; 18 | } 19 | }; 20 | }; 21 | 22 | var closeToc = function() { 23 | $(".toc-wrapper").removeClass('open'); 24 | $("#nav-button").removeClass('open'); 25 | }; 26 | 27 | function loadToc($toc, tocLinkSelector, tocListSelector, scrollOffset) { 28 | var headerHeights = {}; 29 | var pageHeight = 0; 30 | var windowHeight = 0; 31 | var originalTitle = document.title; 32 | 33 | var recacheHeights = function() { 34 | headerHeights = {}; 35 | pageHeight = $(document).height(); 36 | windowHeight = $(window).height(); 37 | 38 | $toc.find(tocLinkSelector).each(function() { 39 | var targetId = $(this).attr('href'); 40 | if (targetId[0] === "#") { 41 | headerHeights[targetId] = $(targetId).offset().top; 42 | } 43 | }); 44 | }; 45 | 46 | var refreshToc = function() { 47 | var currentTop = $(document).scrollTop() + scrollOffset; 48 | 49 | if (currentTop + windowHeight >= pageHeight) { 50 | // at bottom of page, so just select last header by making currentTop very large 51 | // this fixes the problem where the last header won't ever show as active if its content 52 | // is shorter than the window height 53 | currentTop = pageHeight + 1000; 54 | } 55 | 56 | var best = null; 57 | for (var name in headerHeights) { 58 | if ((headerHeights[name] < currentTop && headerHeights[name] > headerHeights[best]) || best === null) { 59 | best = name; 60 | } 61 | } 62 | 63 | // Catch the initial load case 64 | if (currentTop == scrollOffset && !loaded) { 65 | best = window.location.hash; 66 | loaded = true; 67 | } 68 | 69 | var $best = $toc.find("[href='" + best + "']").first(); 70 | if (!$best.hasClass("active")) { 71 | // .active is applied to the ToC link we're currently on, and its parent