German Market – (mini) tutorials

Permalink How to prevent the inclusion of free items in the cart – expanded version

The function used to check the value of each cart item (and in particular to check if the value thereof is zero) can be changed (e.g. by changing the threshold value to €3.71).
Filter name: woocommerce_de_avoid_free_items_limit

add_filter( 'woocommerce_de_avoid_free_items_limit', 'my_woocommerce_de_avoid_free_items_limit')

function my_woocommerce_de_avoid_free_items_limit( $float_number) {
   return 3.71;
}

Permalink How to show the delivery time even if the product is out of stock

The default setting is for the delivery time not to be shown when a product is out of stock. Would you prefer to show the delivery time even if the product is out of stock? The following filter enables you to do so:

// Always show delivery time even if product is out of stock
add_filter( 'woocommerce_de_do_not_show_delivery_time_if_out_of_stock', 'my_woocommerce_de_do_not_show_delivery_time_if_out_of_stock', 10, 2 );

/**
 * Always show delivery time even if product is out of stock
 *
 * @author MarketPress
 * @wp-hook woocommerce_de_do_not_show_delivery_time_if_out_of_stock
 * @param Boolean $boolean
 * @param WC_Product $product
 * @return Boolean
 */
function my_woocommerce_de_do_not_show_delivery_time_if_out_of_stock( $boolean, $product ) {
    return false; // or check something depending on the product
}

Permalink How to show the time of order

The date and time shown reflect the formats defined by the WooCommerce functions wc_date_format and wc_time_format. These are in turn determined by the corresponding WordPress settings. Would you prefer German Market not to influence the date shown on the order summary page? Here’s how to do just that:

/**
 * Don't change date in shop order
 *
 * @author MarketPress
 * @wp-hook woocommerce_de_post_date_column_time_add_time
 * @param Boolean $boolean
 * @return Boolean
 */
function my_woocommerce_de_post_date_column_time_add_time( $boolean ) {
    return false;
}

Here’s how to change or expand how the date and time are shown:

// Change format of date and time in shop order table and refund table
add_filter( 'woocommerce_de_post_date_column_time', 'my_woocommerce_de_post_date_column_time', 10, 2 );

/**
 * Change format of date and time in shop order table and refund table
 *
 * @author MarketPress
 * @wp-hook woocommerce_de_post_date_column_time
 * @param String $string
 * @param Integer $timestamp
 * @return Boolean
 */
function my_woocommerce_de_post_date_column_time( $string, $timestamp ) {
    return $string . ' Uhr'; // add "Uhr" after time
}

The above example adds “Uhr” (the German word for “hour”, which is invariably included when indicating times in German) to the time shown.

Permalink How to solve email compatibility issues in connection with Visual Composer

WGM_Email and the PDF Invoice add-on now use the “remove_vc_shortcodes” method included in the WGM_Template to delete unrendered shortcodes generated by Visual Composer. This prevents shortcodes with the format “av_” or “vc_” from being displayed in emails and PDFs.

If shortcodes with the prefix “lk_” (e.g. [lk_xy] or [lk_abcde]) still exist they can also be deleted. The following filter enables you to do so:

add_filter( 'wgm_vc_regexes', 'my_wgm_vc_regexes' );
function my_wgm_vc_regexes( $regexes ) {
   $regexes[] = "^[(/|)lk_(.*)]^";
   return $regexes;
}

The default setting is for the a tag to close before the German Market product summary in the loop. This can be prevented by adding the following filter to functions.php:

add_filter( ‘wgm_close_a_tag_before_wgm_product_summary_in_loop’, ‘__return_false’ );

Actions “wgm_before_wgm_product_summary_in_loop” and “wgm_after_wgm_product_summary_in_loop” have also been added and can be executed before or after the German Market product summary. The transfer of parameter WC_Product $product makes it possible to carry out other changes using the a tag.