/**
 * Add-to-cart template for composite products.
 *
 * @return void
 */
function wc_cp_add_to_cart()
{
    global $product;
    // Enqueue scripts.
    wp_enqueue_script('wc-add-to-cart-composite');
    // Enqueue styles.
    wp_enqueue_style('wc-composite-single-css');
    // Load NYP scripts.
    if (function_exists('WC_Name_Your_Price')) {
        WC_Name_Your_Price()->display->nyp_scripts();
    }
    // Enqueue Bundle styles.
    if (class_exists('WC_Bundles')) {
        wp_enqueue_style('wc-bundle-css');
    }
    $navigation_style = $product->get_composite_layout_style();
    $components = $product->get_composite_data();
    if (!empty($components)) {
        wc_get_template('single-product/add-to-cart/composite.php', array('navigation_style' => $navigation_style, 'components' => $components, 'product' => $product), '', WC_CP()->plugin_path() . '/templates/');
    }
}
 /**
  * OPC Single-product bundle-type add-to-cart template
  *
  * @param  int  $opc_post_id
  * @return void
  */
 public static function opc_single_add_to_cart_composite($opc_post_id)
 {
     global $product;
     // Enqueue scripts
     wp_enqueue_script('wc-add-to-cart-composite');
     // Enqueue styles
     wp_enqueue_style('wc-composite-single-css');
     // Load NYP scripts
     if (function_exists('WC_Name_Your_Price')) {
         WC_Name_Your_Price()->display->nyp_scripts();
     }
     // Enqueue Bundle styles
     if (class_exists('WC_Bundles')) {
         wp_enqueue_style('wc-bundle-css');
     }
     $navigation_style = $product->get_composite_layout_style();
     $components = $product->get_composite_data();
     ob_start();
     if (!empty($components)) {
         wc_get_template('single-product/add-to-cart/composite.php', array('navigation_style' => $navigation_style, 'components' => $components, 'product' => $product), '', WC_CP()->plugin_path() . '/templates/');
     }
     echo str_replace(array('<form method="post" enctype="multipart/form-data"', '</form>'), array('<div', '</div>'), ob_get_clean());
 }
 /**
  * Runs after adding a bundled item to the cart.
  *
  * @param  int                $product_id
  * @param  int                $quantity
  * @param  int                $variation_id
  * @param  array              $variations
  * @param  array              $bundled_item_cart_data
  * @return void
  */
 public static function before_bundled_add_to_cart($product_id, $quantity, $variation_id, $variations, $bundled_item_cart_data)
 {
     global $Product_Addon_Cart;
     // Set addons and nyp prefixes.
     WC_PB_Compatibility::$addons_prefix = WC_PB_Compatibility::$nyp_prefix = $bundled_item_cart_data['bundled_item_id'];
     // Add-ons cart item data is already stored in the composite_data array, so we can grab it from there instead of allowing Addons to re-add it.
     // Not doing so results in issues with file upload validation.
     if (!empty($Product_Addon_Cart)) {
         remove_filter('woocommerce_add_cart_item_data', array($Product_Addon_Cart, 'add_cart_item_data'), 10, 2);
     }
     // Similarly with NYP.
     if (function_exists('WC_Name_Your_Price')) {
         remove_filter('woocommerce_add_cart_item_data', array(WC_Name_Your_Price()->cart, 'add_cart_item_data'), 5, 3);
     }
 }
Exemplo n.º 4
0
 public static function quick_edit_scripts($hook)
 {
     global $post_type;
     if ($hook == 'edit.php' && $post_type == 'product') {
         $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
         wp_enqueue_script('nyp-quick-edit', WC_Name_Your_Price()->plugin_url() . '/includes/admin/js/nyp-quick-edit' . $suffix . '.js', array('jquery'), WC_Name_Your_Price()->version, true);
     }
 }
 /**
  * Call the Minimum Price Template
  *
  * @param int $product_id
  * @return  void
  * @since 1.0
  */
 public function display_minimum_price($product_id)
 {
     if (!$product_id) {
         global $product;
         $product_id = $product->id;
     }
     // If not NYP quit right now
     if (!WC_Name_Your_Price_Helpers::is_nyp($product_id) && !WC_Name_Your_Price_Helpers::has_nyp($product_id)) {
         return;
     }
     // get the minimum price
     $minimum = WC_Name_Your_Price_Helpers::get_minimum_price($product_id);
     if ($minimum > 0 || WC_Name_Your_Price_Helpers::has_nyp($product_id)) {
         // get the minimum price template
         wc_get_template('single-product/minimum-price.php', array('product_id' => $product_id), FALSE, WC_Name_Your_Price()->plugin_path() . '/templates/');
     }
 }
Exemplo n.º 6
0
            _deprecated_function('display_price_input', '2.0', 'WC_Name_Your_Price()->display->display_price_input');
            return $this->display->display_price_input();
        }
        /**
         * nyp_style function
         *
         * @deprecated As of 2.0, function is now in display class and global replaced with instance
         * @access public
         */
        public function nyp_style()
        {
            _deprecated_function('nyp_style', '2.0', 'WC_Name_Your_Price()->display->nyp_style');
            return $this->display->nyp_style();
        }
    }
    //end class: do not remove or there will be no more guacamole for you
}
// end class_exists check
/**
 * Returns the main instance of WC_Name_Your_Price to prevent the need to use globals.
 *
 * @since  2.0
 * @return WC_Name_Your_Price
 */
function WC_Name_Your_Price()
{
    return WC_Name_Your_Price::instance();
}
// Launch the whole plugin w/ a little backcompat
$GLOBALS['wc_name_your_price'] = WC_Name_Your_Price();
Exemplo n.º 7
0
 /**
  * Support for bundled item NYP.
  *
  * @param  int               $product_id     the product id
  * @param  WC_Bundled_Item   $item           the bundled item
  * @return void
  */
 function nyp_price_input_support($product_id, $item)
 {
     global $product;
     $the_product = !empty($this->compat_product) ? $this->compat_product : $product;
     if ($the_product->product_type == 'bundle' && $the_product->is_priced_per_product() == false) {
         return;
     }
     if (function_exists('WC_Name_Your_Price') && $item->product->product_type == 'simple') {
         $this->nyp_prefix = $item->item_id;
         WC_Name_Your_Price()->display->display_price_input($product_id, $this->nyp_cart_prefix(false, $product_id));
         $this->nyp_prefix = '';
     }
 }
 /**
  * Outputs nyp markup.
  *
  * @param  int $product_id
  * @param  int $component_id
  * @return void
  */
 function nyp_display_support($product_id, $component_id, $product)
 {
     global $woocommerce_composite_products;
     if (!empty($woocommerce_composite_products->api->filter_params) && !$woocommerce_composite_products->api->filter_params['per_product_pricing']) {
         return;
     }
     if (function_exists('WC_Name_Your_Price') && ($product->product_type == 'simple' || $product->product_type == 'bundle')) {
         WC_Name_Your_Price()->display->display_price_input($product_id, '-' . $component_id);
     }
 }
 /**
  * Runs after adding a composited item to the cart.
  *
  * @param  int      $product_id
  * @param  int      $quantity
  * @param  int      $variation_id
  * @param  array    $variations
  * @param  array    $composited_item_cart_data
  * @return void
  */
 public static function after_composited_add_to_cart($product_id, $quantity, $variation_id, $variations, $composited_item_cart_data)
 {
     global $Product_Addon_Cart;
     // Reset addons and nyp prefix
     self::$addons_prefix = self::$nyp_prefix = '';
     if (!empty($Product_Addon_Cart)) {
         add_filter('woocommerce_add_cart_item_data', array($Product_Addon_Cart, 'add_cart_item_data'), 10, 2);
     }
     // Similarly with NYP
     if (function_exists('WC_Name_Your_Price')) {
         add_filter('woocommerce_add_cart_item_data', array(WC_Name_Your_Price()->cart, 'add_cart_item_data'), 5, 3);
     }
 }