public static function output_shipping() { global $post, $thepostid; if (version_compare(WC()->version, '2.3', '<')) { return; } $thepostid = $post->ID; $_product = wc_get_product($thepostid); $delivery_time = wc_gzd_get_gzd_product($_product)->delivery_time; ?> <p class="form-field"> <label for="delivery_time"><?php _e('Delivery Time', 'woocommerce-germanized'); ?> </label> <input type="hidden" class="wc-product-search wc-gzd-delivery-time-search" style="width: 50%" id="delivery_time" name="delivery_time" data-minimum_input_length="1" data-allow_clear="true" data-placeholder="<?php _e('Search for a delivery time…', 'woocommerce-germanized'); ?> " data-action="woocommerce_gzd_json_search_delivery_time" data-multiple="false" data-selected="<?php echo $delivery_time ? $delivery_time->name : ''; ?> " value="<?php echo $delivery_time ? $delivery_time->term_id : ''; ?> " /> </p> <?php // Free shipping woocommerce_wp_checkbox(array('id' => '_free_shipping', 'label' => __('Free shipping?', 'woocommerce-germanized'), 'description' => __('This option disables the "plus shipping costs" notice on product page', 'woocommerce-germanized'))); }
/** * Adds product description to order meta * * @param int $order_id * @param int $item_id * @param object $product * @param int $qty * @param array $args */ public function set_order_meta($order_id, $item_id, $product, $qty, $args) { wc_add_order_item_meta($item_id, '_units', wc_gzd_get_gzd_product($product)->get_product_units_html()); wc_add_order_item_meta($item_id, '_delivery_time', wc_gzd_get_gzd_product($product)->get_delivery_time_html()); wc_add_order_item_meta($item_id, '_item_desc', wc_gzd_get_gzd_product($product)->get_mini_desc()); wc_add_order_item_meta($item_id, '_unit_price', wc_gzd_get_gzd_product($product)->get_unit_html(false)); }
/** * Single Product Tax Info * * @author Vendidero * @package WooCommerceGermanized/Templates * @version 1.0 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly global $product; ?> <?php if (wc_gzd_get_gzd_product($product)->get_tax_info()) { ?> <p class="wc-gzd-additional-info tax-info"><?php echo wc_gzd_get_gzd_product($product)->get_tax_info(); ?> </p> <?php } elseif (get_option('woocommerce_gzd_small_enterprise') == 'yes') { ?> <p class="wc-gzd-additional-info small-business-info"><?php _e('VAT free based on §19 UStG', 'woocommerce-germanized'); ?> </p> <?php }
<?php /** * Single Product Units * * @author Vendidero * @package WooCommerceGermanized/Templates * @version 1.0 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly global $product; ?> <?php if (wc_gzd_get_gzd_product($product)->has_product_units()) { ?> <span class="wc-gzd-additional-info product-units-wrapper product-units"><?php echo wc_gzd_get_gzd_product($product)->get_product_units_html(); ?> </span> <?php }
public static function output($loop, $variation_data, $variation) { if (version_compare(WC()->version, '2.3', '<')) { return self::output_pre($loop, $variation_data); } $_product = wc_get_product($variation); $variation_id = $_product->variation_id; $delivery_time = wp_get_post_terms($variation_id, 'product_delivery_time'); if ($delivery_time && !empty($delivery_time) && is_array($delivery_time)) { $delivery_time = $delivery_time[0]; } ?> <div class="variable_pricing_unit"> <p class="form-row form-row-first"> <label><?php _e('Unit', 'woocommerce-germanized'); ?> :</label> <select name="variable_unit[<?php echo $loop; ?> ]"> <option value="parent" <?php selected(is_null(!empty(wc_gzd_get_gzd_product($_product)->unit) ? wc_gzd_get_gzd_product($_product)->unit : null), true); ?> ><?php _e('None', 'woocommerce-germanized'); ?> </option> <?php foreach (WC_germanized()->units->get_units() as $key => $value) { echo '<option value="' . esc_attr($key) . '" ' . selected($key === (!empty(wc_gzd_get_gzd_product($_product)->unit) ? wc_gzd_get_gzd_product($_product)->unit : ''), true, false) . '>' . esc_html($value) . '</option>'; } ?> </select> </p> <p class="form-row form-row-last"> <label for="variable_unit_product"><?php echo __('Product Units', 'woocommerce-germanized'); ?> : <a class="tips" data-tip="<?php esc_attr_e('Number of units included per default product price. Example: 1000 ml.', 'woocommerce-germanized'); ?> " href="#">[?]</a></label> <input class="input-text wc_input_decimal" size="6" type="text" name="variable_unit_product[<?php echo $loop; ?> ]" value="<?php echo !empty(wc_gzd_get_gzd_product($_product)->unit_product) ? esc_attr(wc_format_localized_decimal(wc_gzd_get_gzd_product($_product)->unit_product)) : ''; ?> " placeholder="" /> </p> <p class="form-row form-row-first"> <label for="variable_unit_base"><?php echo __('Base Price Units', 'woocommerce-germanized'); ?> : <a class="tips" data-tip="<?php esc_attr_e('Base price units. Example base price: 0,99 € / 100 ml. Insert 100 as base price unit amount.', 'woocommerce-germanized'); ?> " href="#">[?]</a></label> <input class="input-text wc_input_decimal" size="6" type="text" name="variable_unit_base[<?php echo $loop; ?> ]" value="<?php echo !empty(wc_gzd_get_gzd_product($_product)->unit_base) ? esc_attr(wc_format_localized_decimal(wc_gzd_get_gzd_product($_product)->unit_base)) : ''; ?> " placeholder="" /> </p> <p class="form-row form-row-full _unit_price_auto_field"> <label for="variable_unit_price_auto_<?php echo $loop; ?> "><?php echo __('Calculation', 'woocommerce-germanized'); ?> :</label> <input class="input-text wc_input_price" id="variable_unit_price_auto_<?php echo $loop; ?> " type="checkbox" name="variable_unit_price_auto[<?php echo $loop; ?> ]" value="yes" <?php checked('yes', get_post_meta($variation_id, '_unit_price_auto', true)); ?> /> <span class="description"> <span class="wc-gzd-premium-desc"><?php echo __('Calculate unit prices automatically based on product price', 'woocommerce-germanized'); ?> </span> <a href="https://vendidero.de/woocommerce-germanized#buy" target="_blank" class="wc-gzd-pro">pro</a> </span> </p> <p class="form-row form-row-first"> <label for="variable_unit_price_regular"><?php echo __('Regular Unit Price', 'woocommerce-germanized') . ' (' . get_woocommerce_currency_symbol() . ')'; ?> :</label> <input class="input-text wc_input_price" size="5" type="text" name="variable_unit_price_regular[<?php echo $loop; ?> ]" value="<?php echo !empty(wc_gzd_get_gzd_product($_product)->unit_price_regular) ? esc_attr(wc_format_localized_price(wc_gzd_get_gzd_product($_product)->unit_price_regular)) : ''; ?> " placeholder="" /> </p> <p class="form-row form-row-last"> <label for="variable_unit_price_sale"><?php echo __('Sale Unit Price', 'woocommerce-germanized') . ' (' . get_woocommerce_currency_symbol() . ')'; ?> :</label> <input class="input-text wc_input_price" size="5" type="text" name="variable_unit_price_sale[<?php echo $loop; ?> ]" value="<?php echo !empty(wc_gzd_get_gzd_product($_product)->unit_price_sale) ? esc_attr(wc_format_localized_price(wc_gzd_get_gzd_product($_product)->unit_price_sale)) : ''; ?> " placeholder="" /> </p> </div> <div class="variable_shipping_time hide_if_variation_virtual"> <p class="form-row form-row-first"> <label for="delivery_time"><?php _e('Delivery Time', 'woocommerce-germanized'); ?> </label> <input type="hidden" class="wc-product-search wc-gzd-delivery-time-search" style="width: 100%" id="variable_delivery_time_<?php echo $loop; ?> " name="variable_delivery_time[<?php echo $loop; ?> ]" data-minimum_input_length="1" data-allow_clear="true" data-placeholder="<?php _e('Same as parent', 'woocommerce-germanized'); ?> " data-action="woocommerce_gzd_json_search_delivery_time" data-multiple="false" data-selected="<?php echo $delivery_time ? $delivery_time->name : ''; ?> " value="<?php echo $delivery_time ? $delivery_time->term_id : ''; ?> " /> </p> </div> <div class="variable_cart_mini_desc"> <p class="form-row form-row-full"> <label for="variable_mini_desc"><?php echo __('Optional Mini Description', 'woocommerce-germanized'); ?> :</label> <textarea rows="3" style="width: 100%" name="variable_mini_desc[<?php echo $loop; ?> ]" id="variable_mini_desc_<?php echo $loop; ?> " class="variable_mini_desc"><?php echo htmlspecialchars_decode(wc_gzd_get_gzd_product($_product)->mini_desc); ?> </textarea> <?php // wp_editor( htmlspecialchars_decode( wc_gzd_get_gzd_product( $_product )->mini_desc ), 'wc_gzd_product_mini_desc_' . $loop, array( 'textarea_name' => 'variable_mini_desc[' . $loop . ']', 'textarea_rows' => 5, 'media_buttons' => false, 'teeny' => true ) ); ?> </p> </div> <?php }
/** * Calculates tax share for shipping/fees * * @param string $type * @return array */ function wc_gzd_get_cart_tax_share($type = 'shipping') { $cart = WC()->cart->get_cart(); $tax_shares = array(); $item_totals = 0; // Get tax classes and tax amounts if (!empty($cart)) { foreach ($cart as $key => $item) { $_product = apply_filters('woocommerce_cart_item_product', $item['data'], $item, $key); // Dont calculate share if is shipping and product is virtual or vat exception if ($type == 'shipping' && $_product->is_virtual() || wc_gzd_get_gzd_product($_product)->is_virtual_vat_exception() && $type == 'shipping') { continue; } $class = $_product->get_tax_class(); if (!isset($tax_shares[$class])) { $tax_shares[$class] = array(); $tax_shares[$class]['total'] = 0; $tax_shares[$class]['key'] = ''; } $tax_shares[$class]['total'] += $item['line_total'] + $item['line_tax']; $tax_shares[$class]['key'] = key($item['line_tax_data']['total']); $item_totals += $item['line_total'] + $item['line_tax']; } } if (!empty($tax_shares)) { $default = $item_totals == 0 ? 1 / sizeof($tax_shares) : 0; foreach ($tax_shares as $key => $class) { $tax_shares[$key]['share'] = $item_totals > 0 ? $class['total'] / $item_totals : $default; } } return $tax_shares; }
<div class="legal-price-info"> <p class="wc-gzd-additional-info"> <?php if (wc_gzd_get_gzd_product($product)->get_tax_info() && get_option('woocommerce_gzd_display_product_detail_tax_info') == 'yes') { ?> <span class="wc-gzd-additional-info tax-info"><?php echo wc_gzd_get_gzd_product($product)->get_tax_info(); ?> </span> <?php } elseif (get_option('woocommerce_gzd_small_enterprise') == 'yes' && get_option('woocommerce_gzd_display_product_detail_small_enterprise') == 'yes') { ?> <span class="wc-gzd-additional-info small-business-info"><?php _e('VAT free based on §19 UStG', 'woocommerce-germanized'); ?> </span> <?php } ?> <?php if (wc_gzd_get_gzd_product($product)->get_shipping_costs_html() && get_option('woocommerce_gzd_display_product_detail_shipping_costs') == 'yes') { ?> <span class="wc-gzd-additional-info shipping-costs-info"><?php echo wc_gzd_get_gzd_product($product)->get_shipping_costs_html(); ?> </span> <?php } ?> </p> </div>
/** * Add delivery time and unit price to variations */ function woocommerce_gzd_add_variation_options($options, $product, $variation) { $options['delivery_time'] = wc_gzd_get_gzd_product($variation)->get_delivery_time_html(); $options['unit_price'] = wc_gzd_get_gzd_product($variation)->get_unit_html(); $options['product_units'] = wc_gzd_get_gzd_product($variation)->get_product_units_html(); $options['tax_info'] = wc_gzd_get_gzd_product($variation)->get_tax_info(); return $options; }
<?php /** * Single Product Shipping Time Info * * @author Vendidero * @package WooCommerceGermanized/Templates * @version 1.0 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly global $product; ?> <?php if (wc_gzd_get_gzd_product($product)->get_delivery_time_term()) { ?> <p class="wc-gzd-additional-info delivery-time-info"><?php echo wc_gzd_get_gzd_product($product)->get_delivery_time_html(); ?> </p> <?php } elseif ($product->is_type('variable')) { ?> <p class="wc-gzd-additional-info delivery-time-info"></p> <?php }