master
λΈλμΉμ λν λ¬Έμ κ° μ¬μ ν μ‘΄μ¬ν©λλ€(WordPress.orgμ λμΌν λ²μ μ΄ μλλλ€ !)woocommerce_rest_prepare_product_cat
λν μ νν°λ₯Ό λ§λλλ€.products/categories
API μλν¬μΈνΈλ₯Ό λλ₯΄μμμ€.μ΄λ¬ν λ¨κ³λ₯Ό μννλ©΄ products/categories
API μλ΅μ μΆκ°λ μμ±μ΄ νμλμ§ μμ΅λλ€.
function prepare_category_images($response, $item, $request)
{
if (empty($response->data)) {
return $response;
}
$response->hello = 'world';
return $response;
}
add_filter("woocommerce_rest_prepare_product_cat", "prepare_category_images", 10, 3);
μ΄λ λ¨μν νμ€ λ²μ£Ό API μλ΅μ μ΄λν©λλ€.
7 => {#349 βΌ
+"id": 60
+"name": "Hooks & Hangers"
+"slug": "hooks-hangers"
+"parent": 0
+"description": ""
+"display": "default"
+"image": {#350 βΆ}
+"menu_order": 7
+"count": 27
+"_links": {#352 βΆ}
}
λ³΄κ³ μΆμλλ°...
7 => {#349 βΌ
+"id": 60
+"name": "Hooks & Hangers"
+"slug": "hooks-hangers"
+"parent": 0
+"description": ""
+"display": "default"
+"image": {#350 βΆ}
+"menu_order": 7
+"count": 27
+"hello": "world"
+"_links": {#352 βΆ}
}
μλ£λ νλͺ©μ [x] νμ
`
### WordPress Environment ###
Home URL: http://wp.website.test
Site URL: http://wp.website.test
WC Version: 3.3.0
Log Directory Writable: β
WP Version: 4.9.5
WP Multisite: β
WP Memory Limit: 256 MB
WP Debug Mode: β
WP Cron: β
Language: en_GB
External object cache: β
### Server Environment ###
Server Info: nginx/1.12.2
PHP Version: 7.1.12
PHP Post Max Size: 128 MB
PHP Time Limit: 60
PHP Max Input Vars: 1000
cURL Version: 7.54.0
LibreSSL/2.0.20
SUHOSIN Installed: β
MySQL Version: 5.7.20
Max Upload Size: 128 MB
Default Timezone is UTC: β
fsockopen/cURL: β
SoapClient: β
DOMDocument: β
GZip: β
Multibyte String: β
Remote Post: β
Remote Get: β
### Database ###
WC Database Version: 3.3.0
WC Database Prefix: wp_
Total Database Size: 49.23MB
Database Data Size: 29.02MB
Database Index Size: 20.21MB
wp_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB
wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB
wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB
wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.05MB
wp_woocommerce_order_items: Data: 0.30MB + Index: 0.11MB
wp_woocommerce_order_itemmeta: Data: 2.52MB + Index: 3.03MB
wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB
wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.05MB
wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB
wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.05MB
wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB
wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB
wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB
wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB
wp_commentmeta: Data: 0.02MB + Index: 0.03MB
wp_comments: Data: 2.52MB + Index: 1.23MB
wp_links: Data: 0.02MB + Index: 0.02MB
wp_options: Data: 7.47MB + Index: 2.47MB
wp_postmeta: Data: 11.52MB + Index: 11.03MB
wp_posts: Data: 3.52MB + Index: 1.20MB
wp_rac_abandoncart: Data: 0.08MB + Index: 0.00MB
wp_rac_email_logs: Data: 0.02MB + Index: 0.00MB
wp_rac_templates_email: Data: 0.02MB + Index: 0.00MB
wp_termmeta: Data: 0.06MB + Index: 0.03MB
wp_terms: Data: 0.05MB + Index: 0.03MB
wp_term_relationships: Data: 0.34MB + Index: 0.30MB
wp_term_taxonomy: Data: 0.06MB + Index: 0.03MB
wp_usermeta: Data: 0.14MB + Index: 0.14MB
wp_users: Data: 0.02MB + Index: 0.05MB
wp_wc_download_log: Data: 0.02MB + Index: 0.03MB
wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB
wp_woocommerce_termmeta: Data: 0.02MB + Index: 0.03MB
wp_yith_wcwl: Data: 0.02MB + Index: 0.05MB
wp_yith_wcwl_lists: Data: 0.02MB + Index: 0.03MB
### Post Type Counts ###
acf-field: 1
acf-field-group: 1
attachment: 2938
customize_changeset: 1
mc4wp-form: 1
ml-slider: 1
nav_menu_item: 19
page: 25
post: 9
product: 772
product_variation: 341
revision: 82
shop_coupon: 11
shop_order: 2216
shop_order_refund: 8
sidebar: 1
### Security ###
Secure connection (HTTPS): βYour store is not using HTTPS. Learn more about HTTPS and SSL Certificates.
Hide errors from visitors: βError messages should not be shown to visitors.
### Active Plugins (5) ###
Advanced Custom Fields PRO: by Elliot Condon β 5.6.10
Regenerate Thumbnails: by Alex Mills (Viper007Bond) β 3.0.2
WooCommerce POS: by kilbot β 0.4.18
WooCommerce Shipping Pro: by WooForce β 2.1.1 β Not tested with the active version of WooCommerce
WooCommerce: by Automattic β 3.4.0-dev
### Settings ###
API Enabled: β
Force SSL: β
Currency: GBP (Β£)
Currency Position: left
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 2
Taxonomies: Product Types: external (external)
grouped (grouped)
simple (simple)
variable (variable)
Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)
### WC Pages ###
Shop base: #4 - /shop/
Cart: #5 - /my-account/cart/
Checkout: #6 - /my-account/checkout/
My account: #7 - /my-account/
Terms and conditions: #254 - /information/terms-conditions/
### Theme ###
Name: Mench Living
Version: 1.0
Author URL: https://youi.design
Child Theme: β
Parent Theme Name: Storefront
Parent Theme Version: 2.2.8
Parent Theme Author URL: https://woocommerce.com/
WooCommerce Support: β
### Templates ###
Overrides: β
`
μ°Έκ³ λ‘ μ¬μ΄νΈμ APIμ λλ¬ν λ debug.logμ μ€λ₯κ° νμλμ§ μμ΅λλ€.
μ΄ νν°λ₯Ό μ¬μ©νμ¬ μ©μ΄ λ°μ΄ν°λ₯Ό μμ νλ €λ©΄ $response
μλλΌ $response->data
λ₯Ό μ‘°μν΄μΌ ν©λλ€. μλ μ½λλ μ 곡ν μμ μμ μνλ μΆλ ₯μ μμ±ν΄μΌ ν©λλ€.
function prepare_category_images( $response, $item, $request ) {
if ( empty( $response->data ) ) {
return $response;
}
$response->data['hello'] = 'world';
return $response;
}
add_filter( 'woocommerce_rest_prepare_product_cat', 'prepare_category_images', 10, 3 );
cc @claudiosanches νν° λ¬Έμλ₯Ό κ°μ νμ¬ μ΄κ²μ λ λͺ ννκ² νκ±°λ λ΄κ° λλ½λ κ²μ΄ μλ κ²½μ°λ₯Ό λλΉνμ¬.
λμμ£Όμ μ κ°μ¬ν©λλ€ @rodrigoprimo
μ΄ μ½λλ₯Ό μ¬μ©νμ¬ μΉ΄ν κ³ λ¦¬μ μ΄λ―Έμ§ μΈλ€μΌμ woocommerce API μλν¬μΈνΈμ μΆκ°νμ΅λλ€.
/**
* Add image sizes to product category API index
*
*/
function prepare_category_images($response, $item, $request)
{
global $_wp_additional_image_sizes;
if (empty($response->data)) {
return $response;
}
$id = $response->data['image']['id'];
foreach ($_wp_additional_image_sizes as $size => $value) {
$image_info = wp_get_attachment_image_src($id, $size);
$response->data["image"][$size] = $image_info[0];
}
return $response;
}
add_filter("woocommerce_rest_prepare_product_cat", "prepare_category_images", 10, 3);
κ°μ₯ μ μ©ν λκΈ
μ΄ νν°λ₯Ό μ¬μ©νμ¬ μ©μ΄ λ°μ΄ν°λ₯Ό μμ νλ €λ©΄
$response
μλλΌ$response->data
λ₯Ό μ‘°μν΄μΌ ν©λλ€. μλ μ½λλ μ 곡ν μμ μμ μνλ μΆλ ₯μ μμ±ν΄μΌ ν©λλ€.cc @claudiosanches νν° λ¬Έμλ₯Ό κ°μ νμ¬ μ΄κ²μ λ λͺ ννκ² νκ±°λ λ΄κ° λλ½λ κ²μ΄ μλ κ²½μ°λ₯Ό λλΉνμ¬.