{"id":18364,"date":"2024-07-30T19:36:57","date_gmt":"2024-07-30T17:36:57","guid":{"rendered":"https:\/\/www.welaunch.io\/en\/?post_type=faq&#038;p=18364"},"modified":"2024-07-30T19:36:57","modified_gmt":"2024-07-30T17:36:57","slug":"bottle-deposit-german-market-support","status":"publish","type":"faq","link":"https:\/\/www.welaunch.io\/en\/knowledge-base\/faq\/bottle-deposit-german-market-support\/","title":{"rendered":"Bottle deposit German Market support"},"content":{"rendered":"<p>To work with our WooCommerce bottle deposit plugin and German market pleae add this code to your child theme functions.php:<\/p>\n<pre>\r\nadd_action( 'after_setup_theme', function() {\r\n\t\r\n\tremove_filter( 'woocommerce_cart_totals_fee_html', array( 'WGM_Fee', 'show_gateway_fees_tax' ), 10, 2 );\r\n\tremove_filter( 'woocommerce_cart_totals_get_fees_from_cart_taxes', array( 'WGM_Fee', 'cart_totals_get_fees_from_cart_taxes' ), 10, 3 );\t\r\n\tremove_filter( 'woocommerce_get_order_item_totals', array( 'WGM_Fee', 'add_tax_string_to_fee_order_item' ), 10, 2 );\r\n\tremove_filter( 'woocommerce_order_get_tax_totals', array( 'WGM_Fee', 'add_fee_to_order_tax_totals' ), 10, 2 );\r\n\t\r\n\tadd_filter( 'woocommerce_cart_totals_fee_html', function( $fee_html, $fee ) {\r\n\t\t\r\n\t\tif ( class_exists( 'WGM_Tax' ) ) {\r\n\t\t\t$tax_display \t\t= get_option( 'woocommerce_tax_display_cart' );\r\n\r\n\t\t\tif ( isset( $fee->tax_data ) && is_array( $fee->tax_data ) ) {\r\n\t\t\t\tforeach ( $fee->tax_data as $rate_id => $amount ) {\r\n\t\t\t\t\t$tax_label \t= WC_Tax::get_rate_label( $rate_id );\r\n\t\t\t\t\t$rate_percent = floatval( WC_Tax::get_rate_percent( $rate_id ) );\r\n\t\t\t\t\t$tax_string = WGM_Tax::get_excl_incl_tax_string( $tax_label, $tax_display, $rate_percent, wc_price( $fee->tax ) );\r\n\t\t\t\t\t$fee_html .= sprintf( '<br class=\"wgm-break\" \/><span class=\"wgm-tax product-tax\"> %s <\/span>', $tax_string );\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\t\t\r\n\t\t\r\n\t\treturn $fee_html;\r\n\t}, 10, 2 );\r\n\t\r\n\tadd_filter( 'woocommerce_get_order_item_totals', function( $items, $order ) {\r\n\t\t\r\n\t\tif ( is_a( $order, 'WC_Order_Refund' ) ) {\r\n\t\t\t$parent_id = $order->get_parent_id();\r\n\t\t\t$order = wc_get_order( $parent_id );\r\n\t\t}\r\n\t\t\r\n\t\t$tax_display = get_option( 'woocommerce_tax_display_cart' );\r\n\t\t\r\n\t\tforeach ( $order->get_fees() as $key => $fee ) {\r\n\r\n\t\t\t$search_key = 'fee_' . $key;\r\n\r\n\t\t\tif ( ! array_key_exists( $search_key, $items ) ) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t$rate = array();\r\n\t\t\t$taxes = $fee->get_taxes();\r\n\t\t\t\r\n\t\t\tif ( isset( $taxes[ 'total' ] ) ) {\r\n\r\n\t\t\t\tforeach ( $taxes[ 'total' ] as $tax_rate_key => $tax_infos ) {\r\n\r\n\t\t\t\t\t$label = apply_filters( 'wgm_translate_tax_label', WC_Tax::get_rate_label( $tax_rate_key ) );\r\n\t\t\t\t\t$sum   = $fee->get_total_tax();\r\n\t\t\t\t\t$rate  = floatval( WC_Tax::get_rate_percent( $tax_rate_key ) );\r\n\t\t\t\t\t$tax_string = WGM_Tax::get_excl_incl_tax_string( $label, $tax_display, $rate, wc_price( $sum ) );\r\n\t\t\t\t\t$fee_html .= sprintf( '<br class=\"wgm-break\" \/><span class=\"wgm-tax product-tax\"> %s <\/span>', $tax_string );\r\n\t\t\t\t\t$items[ $search_key ][ 'value' ] .= $fee_html;\r\n\t\t\t\t\t\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn $items;\r\n\t\t\r\n\t}, 10, 2 );\r\n});\r\n<\/pre>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","product_cat":[],"class_list":["post-18364","faq","type-faq","status-publish","hentry","faq_topics-woocommerce-bottle-deposit"],"_links":{"self":[{"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/faq\/18364","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/faq"}],"about":[{"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/types\/faq"}],"author":[{"embeddable":true,"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/comments?post=18364"}],"version-history":[{"count":1,"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/faq\/18364\/revisions"}],"predecessor-version":[{"id":18365,"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/faq\/18364\/revisions\/18365"}],"wp:attachment":[{"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/media?parent=18364"}],"wp:term":[{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/product_cat?post=18364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}