0
0
Wordpressframework~10 mins

WooCommerce setup 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 activate the WooCommerce plugin in WordPress.

Wordpress
<?php
function activate_woocommerce() {
    activate_plugin('[1]');
}
?>
Drag options to blanks, or click blank then click option'
Aakismet/akismet.php
Bjetpack/jetpack.php
Cwoocommerce/woocommerce.php
Dcontact-form-7/wp-contact-form-7.php
Attempts:
3 left
💡 Hint
Common Mistakes
Using plugin paths of other plugins like Jetpack or Akismet.
Forgetting to include the main plugin file name.
2fill in blank
medium

Complete the code to add WooCommerce support to your WordPress theme.

Wordpress
<?php
function theme_setup() {
    add_theme_support('[1]');
}
add_action('after_setup_theme', 'theme_setup');
Drag options to blanks, or click blank then click option'
Awoocommerce
Bmenus
Ccustom-logo
Dpost-thumbnails
Attempts:
3 left
💡 Hint
Common Mistakes
Adding support for unrelated features like 'post-thumbnails' instead of 'woocommerce'.
Not hooking the function to 'after_setup_theme'.
3fill in blank
hard

Fix the error in the code to enqueue WooCommerce styles properly.

Wordpress
<?php
function enqueue_woocommerce_styles() {
    if (class_exists('[1]')) {
        wp_enqueue_style('woocommerce-general');
    }
}
add_action('wp_enqueue_scripts', 'enqueue_woocommerce_styles');
Drag options to blanks, or click blank then click option'
AWooCommerce_Styles
BWooCommerce
Cwoocommerce
DWC_Styles
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'woocommerce' which is not a class name.
Using incorrect class names like 'WC_Styles'.
4fill in blank
hard

Fill both blanks to create a shortcode that displays WooCommerce products.

Wordpress
<?php
function display_products_shortcode() {
    return do_shortcode('[1]');
}
add_shortcode('[2]', 'display_products_shortcode');
Drag options to blanks, or click blank then click option'
A[products limit="4" columns="2"]
B[recent_products]
Cproducts_list
Dshow_products
Attempts:
3 left
💡 Hint
Common Mistakes
Using shortcode tags with brackets in add_shortcode.
Using incorrect shortcode tags that do not match the function.
5fill in blank
hard

Fill all three blanks to register a custom WooCommerce product tab.

Wordpress
<?php
function add_custom_product_tab([1]) {
    [2]['custom_tab'] = array(
        'title' => __('Custom Tab', 'text-domain'),
        'priority' => 50,
        'callback' => '[3]'
    );
    return [1];
}
add_filter('woocommerce_product_tabs', 'add_custom_product_tab');
Drag options to blanks, or click blank then click option'
A$tabs
Ccustom_tab_content
Dcustom_tab_callback
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for parameter and return value.
Using incorrect callback function names.