0
0
Wordpressframework~10 mins

Shipping configuration in Wordpress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add a flat rate shipping method in WooCommerce.

Wordpress
add_filter('woocommerce_shipping_methods', function($methods) { $methods['flat_rate'] = [1]; return $methods; });
Drag options to blanks, or click blank then click option'
AWC_Shipping_Flat_Rate
B'FlatRate'
C'flat_rate_shipping'
D'shipping_flat_rate'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect class names or strings that are not recognized by WooCommerce.
2fill in blank
medium

Complete the code to set the shipping zone to 'US' in WooCommerce.

Wordpress
$zone = new WC_Shipping_Zone([1]);
Drag options to blanks, or click blank then click option'
A0
B'US'
C1
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using country codes instead of zone IDs.
3fill in blank
hard

Fix the error in the code to add a shipping method to a zone.

Wordpress
$zone = new WC_Shipping_Zone(1); $zone->add_shipping_method([1]);
Drag options to blanks, or click blank then click option'
Aflat_rate
B'flat_rate'
C'FlatRate'
Dnew WC_Shipping_Flat_Rate()
Attempts:
3 left
💡 Hint
Common Mistakes
Passing an object or class name instead of the method ID string.
4fill in blank
hard

Fill both blanks to create a shipping method instance and set its cost.

Wordpress
$method = new [1](); $method->[2] = '10';
Drag options to blanks, or click blank then click option'
AWC_Shipping_Flat_Rate
Bcost
Cset_cost
DWC_Shipping_Free_Shipping
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong class names or method names to set cost.
5fill in blank
hard

Fill all three blanks to register a custom shipping method class in WooCommerce.

Wordpress
add_filter('woocommerce_shipping_methods', function($methods) { $methods[[1]] = '[2]'; return $methods; }); class [3] extends WC_Shipping_Method {}
Drag options to blanks, or click blank then click option'
A'custom_shipping'
BCustom_Shipping_Method
CWC_Custom_Shipping
D'Custom_Shipping_Method'
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching class names or method IDs.