function on_init() { if (wc_is_21x()) { add_filter('woocommerce_loop_add_to_cart_link', array($this, 'get_add_to_cart_link21'), 99, 2); } else { add_filter('woocommerce_loop_add_to_cart_link', array($this, 'get_add_to_cart_link'), 99, 3); } }
public function on_woocommerce_init() { global $wc_cvo; if ($wc_cvo->setting('wc_cvo_prices') != 'enabled' || $wc_cvo->setting('wc_cvo_atc') != 'enabled') { if ($wc_cvo->setting('wc_cvo_prices') == 'secured' && !catalog_visibility_user_has_access() || $wc_cvo->setting('wc_cvo_prices') == 'disabled') { add_filter('woocommerce_grouped_price_html', array(&$this, 'on_price_html'), 100, 2); add_filter('woocommerce_variable_price_html', array(&$this, 'on_price_html'), 100, 2); add_filter('woocommerce_sale_price_html', array(&$this, 'on_price_html'), 100, 2); add_filter('woocommerce_price_html', array(&$this, 'on_price_html'), 100, 2); add_filter('woocommerce_empty_price_html', array(&$this, 'on_price_html'), 100, 2); add_filter('woocommerce_variable_sale_price_html', array(&$this, 'on_price_html'), 100, 2); add_filter('woocommerce_variable_free_sale_price_html', array(&$this, 'on_price_html'), 100, 2); add_filter('woocommerce_variable_free_price_html', array(&$this, 'on_price_html'), 100, 2); add_filter('woocommerce_variable_empty_price_html', array(&$this, 'on_price_html'), 100, 2); add_filter('woocommerce_free_sale_price_html', array(&$this, 'on_price_html'), 100, 2); add_filter('woocommerce_free_price_html', array(&$this, 'on_price_html'), 100, 2); if (wc_is_21x()) { //2.1x add_filter('woocommerce_cart_item_price', array($this, 'on_cart_item_price_html'), 100, 2); } else { //2.0x add_filter('woocommerce_cart_item_price_html', array($this, 'on_cart_item_price_html'), 100, 2); } } //Configure replacement HTML and content. //Note: If prices are disabled, and purchases are enabled, the alternate add-to-cart button content will still be used. // Add to cart only makes sense when prices are visibile. if ($wc_cvo->setting('wc_cvo_atc') == 'secured' && !catalog_visibility_user_has_access() || $wc_cvo->setting('wc_cvo_atc') == 'disabled' || ($wc_cvo->setting('wc_cvo_prices') == 'secured' && !catalog_visibility_user_has_access() || $wc_cvo->setting('wc_cvo_prices') == 'disabled')) { //Bulk variations compatibility add_filter('woocommerce_bv_render_form', '__return_false'); //Wishlist compatibility add_action('woocommerce_wishlist_user_can_purcahse', array($this, 'on_wishlist_user_can_purcahse'), 100, 2); add_action('woocommerce_before_shop_loop_item', array(&$this, 'before_shop_loop_item'), 0); add_action('woocommerce_before_add_to_cart_button', array(&$this, 'on_before_add_to_cart_button'), 1); add_action('woocommerce_after_add_to_cart_button', array(&$this, 'on_after_add_to_cart_button'), 999); remove_shortcode('woocommerce_cart'); remove_shortcode('woocommerce_checkout'); remove_shortcode('woocommerce_order_tracking'); add_shortcode('woocommerce_cart', array(&$this, 'get_woocommerce_cart')); add_shortcode('woocommerce_checkout', array(&$this, 'get_woocommerce_checkout')); add_shortcode('woocommerce_order_tracking', array(&$this, 'get_woocommerce_order_tracking')); } } }
function get_form($options) { global $woocommerce; $product = null; if (function_exists('get_product')) { $product = get_product($this->product_id); } else { $product = new WC_Product($this->product_id); } extract(shortcode_atts(array('display_title' => true, 'display_description' => true, 'display_inactive' => false, 'field_values' => false, 'ajax' => false, 'tabindex' => 1, 'label_subtotal' => __('Subtotal', 'wc_gf_addons'), 'label_options' => __('Options', 'wc_gf_addons'), 'label_total' => __('Total', 'wc_gf_addons'), 'disable_label_subtotal' => 'no', 'disable_label_options' => 'no', 'disable_label_total' => 'no', 'disable_calculations' => 'no'), $options)); //Get the form meta so we can make sure the form exists. $form_meta = RGFormsModel::get_form_meta($this->form_id); if (!empty($form_meta)) { if (!empty($_POST)) { $_POST['gform_submit'] = isset($_POST['gform_old_submit']) ? $_POST['gform_old_submit'] : ''; $_POST['gform_old_submit'] = $_POST['gform_submit']; } $form = RGForms::get_form($this->form_id, $display_title, $display_description, $display_inactive, $field_values, $ajax, $tabindex); unset($_POST['gform_submit']); $form = str_replace('</form>', '', $form); $form = str_replace('gform_submit', 'gform_old_submit', $form); $this->current_page = GFFormDisplay::get_current_page($this->form_id); $this->next_page = $this->current_page + 1; $this->previous_page = $this->current_page - 1; $this->next_page = $this->next_page > $this->get_max_page_number($form_meta) ? 0 : $this->next_page; if ($product->product_type == 'variable' || $product->product_type == 'variable-subscription') { echo '<div class="gform_variation_wrapper gform_wrapper single_variation_wrap">'; } else { echo '<div class="gform_variation_wrapper gform_wrapper">'; } if ($product->is_type('variable')) { //echo '<input type="hidden" name="add-to-cart" value="variation" />'; echo '<input type="hidden" id="product_id" name="product_id" value="' . $this->product_id . '" />'; } elseif ($product->has_child()) { //echo '<input type="hidden" name="add-to-cart" value="group" />'; echo '<input type="hidden" id="product_id" name="product_id" value="' . $this->product_id . '" />'; } else { //echo '<input type="hidden" name="add-to-cart" value="' . $this->product_id . '" />'; echo '<input type="hidden" id="product_id" name="product_id" value="' . $this->product_id . '" />'; } if (wc_is_21x()) { wp_nonce_field('add_to_cart'); } else { $woocommerce->nonce_field('add_to_cart'); } echo '<a id="_form_' . $this->form_id . '" href="#_form_' . $this->form_id . '" class="gform_anchor"></a>'; echo $form; echo '<input type="hidden" name="gform_form_id" id="gform_form_id" value="' . $this->form_id . '" />'; echo '<input type="hidden" id="woocommerce_get_action" value="" />'; echo '<input type="hidden" id="woocommerce_product_base_price" value="' . $product->get_price() . '" />'; $description_class = rgar($form_meta, "descriptionPlacement") == "above" ? "description_above" : "description_below"; ?> <?php $this->on_print_scripts(); if ($disable_calculations == 'no') { ?> <div class="product_totals"> <ul id="gform_totals_<?php echo $this->form_id; ?> " class="gform_fields <?php echo $form_meta['labelPlacement'] . ' ' . $description_class; ?> "> <li class="gfield" <?php if ($disable_label_subtotal == 'yes') { echo 'style="display:none;"'; } ?> > <label class="gfield_label"><?php echo $label_subtotal; ?> </label> <div class="ginput_container"> <span class="formattedBasePrice ginput_total"></span> </div> </li> <li class="gfield" <?php if ($disable_label_options == 'yes') { echo 'style="display:none;"'; } ?> > <label class="gfield_label"><?php echo $label_options; ?> </label> <div class="ginput_container"> <span class="formattedVariationTotal ginput_total"></span> </div> </li> <li class="gfield" <?php if ($disable_label_total == 'yes') { echo 'style="display:none;"'; } ?> > <label class="gfield_label"><?php echo $label_total; ?> </label> <div class="ginput_container"> <span class="formattedTotalPrice ginput_total"></span> </div> </li> </ul> </div> <style> .single_variation .price { display:none !important; } </style> <?php } ?> <style> .hidden-total { display:none !important; } </style> <?php echo '</div>'; } }