Skip to content

Instantly share code, notes, and snippets.

View somewherewarm-snippets's full-sized avatar

SomewhereWarm Support somewherewarm-snippets

  • WooCommerce
  • Athens
View GitHub Profile
View cp - Default Component Option Sorting Options
$component_orderby_options = apply_filters( 'woocommerce_composite_component_orderby', array(
'default' => __( 'Default sorting', 'woocommerce' ),
'popularity' => __( 'Sort by popularity', 'woocommerce' ),
'date' => __( 'Sort by newness', 'woocommerce' ),
'price' => __( 'Sort by price: low to high', 'woocommerce' ),
'price-desc' => __( 'Sort by price: high to low', 'woocommerce' )
), $component_id, $this );
View cp-js-api-example-get_composite_configuration
{
"1425027293": {
"title": "Deck",
"selection_title": "Chocolate Marc Johnson Subtle Square",
"selection_meta": [],
"product_id": "100",
"variation_id": "",
"product_valid": true,
"variation_valid": true,
"quantity": 1,
View cp-js-api-bootstrapping.js
;( function ( $, window, document, undefined ) {
$( '.composite_data' )
.on( 'wc-composite-initializing', function( event, composite ) {
// Add your code here.
} );
} ) ( jQuery, window, document );
View cp-rest-api-add-component.txt
curl -X PUT https://example.com/wp-json/wc/v2/products/133 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"composite_components": [
{
"title": "Your Free Poster",
"description": "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.",
"query_type": "product_ids",
"query_ids": [ 70 ],
View cp-rest-api-add-composite-to-order.txt
curl -X PUT https://example.com/wp-json/wc/v2/orders/199 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-k \
-d '{
"line_items": [
{
"product_id": 101,
"quantity": 1,
"composite_configuration": [
View cp-rest-api-create-composite.txt
curl -X POST https://example.com/wp-json/wc/v2/products \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Build Your Ninja Outfit",
"type": "composite",
"description": "In pretium enim justo, at ornare libero aliquam quis. Nullam imperdiet rutrum volutpat. Suspendisse aliquet ex in ex volutpat vestibulum. Curabitur ultrices convallis condimentum.",
"short_description": "In pretium enim justo, at ornare libero aliquam quis.",
"categories": [
{
View cp-rest-api-delete-component.txt
curl -X PUT https://example.com/wp-json/wc/v2/products/133 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"composite_components": [
{
"id": "123456789",
"delete": true
}
]
View cp-rest-api-modify-component.txt
curl -X PUT https://example.com/wp-json/wc/v2/products/133 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"composite_components": [
{
"id": "123456789",
"title": "Your Poster Offer",
"optional": true,
"discount": "50.0",
View pb-rest-api-create-bundle.txt
curl -X POST https://example.com/wp-json/wc/v1/products \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Happy Ninja Bundle",
"type": "bundle",
"regular_price": "53.0",
"sale_price": "37.0",
"description": "In pretium enim justo, at ornare libero aliquam quis. Nullam imperdiet rutrum volutpat. Suspendisse aliquet ex in ex volutpat vestibulum. Curabitur ultrices convallis condimentum.",
"short_description": "In pretium enim justo, at ornare libero aliquam quis.",
View pb-rest-api-add-bundled-item.txt
curl -X PUT https://example.com/wp-json/wc/v1/products/133 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"bundled_items": [
{
"product_id": 70,
"quantity_min": 1,
"quantity_max": 1,