0
0
Wordpressframework~10 mins

Why WooCommerce powers ecommerce in Wordpress - Test Your Understanding

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

Complete the code to activate WooCommerce plugin in WordPress.

Wordpress
<?php
/* Plugin Name: Sample Store */
function activate_woocommerce() {
    if ( ! class_exists( '[1]' ) ) {
        // WooCommerce is not active
    }
}
add_action( 'plugins_loaded', 'activate_woocommerce' );
Drag options to blanks, or click blank then click option'
AWooCommerceActive
BWooCommerce
CWC_Store
DWooCommercePlugin
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect class names like WC_Store or WooCommercePlugin.
2fill in blank
medium

Complete the code to add a WooCommerce product to the cart.

Wordpress
function add_product_to_cart() {
    $product_id = 123;
    WC()->cart->[1]( $product_id );
}
Drag options to blanks, or click blank then click option'
Acart_add
Binsert_product
Cadd_item
Dadd_to_cart
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like add_item or cart_add.
3fill in blank
hard

Fix the error in the WooCommerce shortcode to display products.

Wordpress
echo do_shortcode( '[products [1]="4"]' );
Drag options to blanks, or click blank then click option'
Acount
Blimit
Cnumber
Ditems
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'count' or 'limit' which are not valid shortcode attributes.
4fill in blank
hard

Fill both blanks to create a WooCommerce product query for featured products.

Wordpress
$args = [
    'post_type' => 'product',
    'meta_key' => '[1]',
    'meta_value' => '[2]'
];
Drag options to blanks, or click blank then click option'
A_featured
Byes
Ctrue
D_is_featured
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect meta keys or boolean true instead of string 'yes'.
5fill in blank
hard

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

Wordpress
add_filter( 'woocommerce_product_tabs', function( $tabs ) {
    $tabs['[1]'] = [
        'title'    => '[2]',
        'callback' => '[3]'
    ];
    return $tabs;
});
Drag options to blanks, or click blank then click option'
Acustom_tab
BAdditional Info
Ccustom_tab_content
Dextra_tab
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid keys or mismatched callback function names.