'product', 'post_status' => 'publish', 'posts_per_page' => '-1', 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $wg_cat ) ), 'meta_query' => array( array( 'key' => '_stock_status', 'value' => 'instock' ) ), ); $product = get_posts( $args ); } ?>

'product', 'post_status' => 'publish', 'posts_per_page' => '-1', 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $wg_cat ) ), 'meta_query' => array( array( 'key' => '_stock_status', 'value' => 'instock' ) ), ); $product = get_posts( $args ); } if( $gw_ckout_enable == "enable"){?>
' ) !== false ) { $name = sprintf( $ocwg_gift_text, '' . get_the_title( $item['product_id'] ) . '' ); } else { $name = sprintf( $ocwg_gift_text, get_the_title( $item['product_id'] ) ); } $item_name .= ' ' . apply_filters( 'ocwg_item_name', $name, $item ) . ''; } return $item_name; } function OCGW_init_action() { if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'ocgw_giftred_wrapper' && isset($_REQUEST['ocgw_prod']) && $_REQUEST['ocgw_prod'] !='') { $gift_wrapper_message = sanitize_text_field($_REQUEST['gift_wrapper_message']); $prod_id = sanitize_text_field($_REQUEST['ocgw_prod']); $redpage = sanitize_text_field($_REQUEST['redpage']); $product = wc_get_product( $prod_id ); if(!empty($gift_wrapper_message)){ $gift_wrapper_message = sanitize_text_field($_REQUEST['gift_wrapper_message']); update_post_meta($prod_id,"add_wrapper",$gift_wrapper_message); } $prod_type = $product->get_type(); if($prod_type == 'simple') { WC()->cart->add_to_cart($prod_id, 1, NULL,NULL, array('gift_wrapper' => 'gift_wrapper')); if($redpage == 'cart') { wp_safe_redirect( wc_get_cart_url() ); $gift_wrapper_added_message = __('Gift Wrapper Add Successfully In Cart.','add-gift-wrapper-for-woocommerce'); wc_add_notice( apply_filters( 'wc_add_to_cart_message', $gift_wrapper_added_message, $prod_id ) ); } elseif ($redpage == 'checkout') { wp_safe_redirect( wc_get_checkout_url() ); $gift_wrapper_added_message = __('Gift Wrapper Add Successfully In Cart.','add-gift-wrapper-for-woocommerce'); wc_add_notice( apply_filters( 'wc_add_to_cart_message', $gift_wrapper_added_message, $prod_id ) ); } exit; } else { $url = get_permalink( $prod_id ); wp_redirect($url); exit; } } } function OCWG_before_add_to_cart_btn(){ global $ocgw_comman; $wg_cat = get_option( 'gw_gift_wrapper_combo' ); $wg_eligiblity_btn_text = $ocgw_comman['gw_gift_wrapper_title']; $gw_gift_rule = $ocgw_comman['gw_gift_rule']; if($gw_gift_rule == "productbase"){ $product = get_option('gw_combo'); }else{ $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => '-1', 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $wg_cat ) ), 'meta_query' => array( array( 'key' => '_stock_status', 'value' => 'instock' ) ), ); $product = get_posts( $args ); } if($ocgw_comman['gw_gift_wrapper_single_product_page']== 'enable'){?>
">

get_meta('add_wrapper') ) { $item_name .= '
' . __("Wrapper Message", "woocommerce") . ': ' . $value1 . ''; } return $item_name; } function custom_checkout_cart_item_name( $item_qty, $cart_item, $cart_item_key ) { if( $value1 = $cart_item['data']->get_meta('add_wrapper') ) { $item_qty .= '
' . __("Wrapper Message", "woocommerce") . ': ' . $value1 . ''; } return $item_qty; } function custom_order_item_name( $item_name, $item ) { $product = $item->get_product(); if( $value1 = $product->get_meta('add_wrapper') ) { $item_name .= '
' . __("Wrapper Message", "woocommerce") . ': ' . $value1 . ''; } return $item_name; } function OCWG_order_item_meta( $item_id, $cart_item ) { // get product meta $event_time = get_post_meta( $cart_item[ 'product_id' ], 'add_wrapper', true ); // if not empty, update order item meta if( ! empty( $event_time ) ) { wc_update_order_item_meta( $item_id, 'Wrapper Message', $event_time ); } } function add_cart_item_data( $cart_item_meta, $product_id ) { if ( isset( $_POST ['ocgw_prod_single'] ) ) { $product = wc_get_product( $_POST ['ocgw_prod_single'] ); $title = $product->get_name(); $custom_price = $product->get_price(); $custom_price_html = $product->get_price_html(); //$custom_data [ 'customer_name' ] = isset( $_POST ['customer_name'] ) ? sanitize_text_field ( $_POST ['customer_name'] ) : "" ; $custom_data ['custom_price'] = $custom_price; $custom_data ['gift_wrapper_message'] = isset( $_POST ['gift_wrapper_message'] ) ? sanitize_text_field ( $_POST ['gift_wrapper_message'] ): "" ; $custom_data ['Gift_wrapper_title'] = $title; $custom_data ['custom_price_html'] = $custom_price_html; $cart_item_meta['custom_data'] = $custom_data ; } return $cart_item_meta; } function get_item_data ( $other_data, $cart_item ) { if ( isset( $cart_item [ 'custom_data' ] ) && !empty($cart_item ['custom_data']) ) { $custom_data = $cart_item [ 'custom_data' ]; if(!empty($custom_data ['Gift_wrapper_title'])){ $other_data[] = array( 'name' => '','display' => $custom_data['Gift_wrapper_title']."(".$custom_data ['custom_price_html'].")"); } if(!empty($custom_data ['gift_wrapper_message'])){ $other_data[] = array( 'name' => 'Message','display' => $custom_data['gift_wrapper_message'] ); } } return $other_data; } function add_order_item_meta ( $item_id, $values ) { if ( isset( $values [ 'custom_data' ] ) ) { $custom_data = $values [ 'custom_data' ]; wc_add_order_item_meta( $item_id, 'Message', $custom_data['customer_message'] ); wc_add_order_item_meta( $item_id, 'Gift_wrapper_title', $custom_data['Gift_wrapper_title'] ); wc_add_order_item_meta( $item_id, 'custom_price_html', $custom_data['custom_price_html'] ); } } function add_custom_price( $cart ) { $cart_data = WC()->cart->get_cart(); foreach($cart_data as $cart_item) { if(!empty($cart_item [ 'custom_data' ])){ $product = wc_get_product($cart_item['product_id'] ); $custom_data = $cart_item [ 'custom_data' ]; $product_gi_price = $product->get_price(); $product_gift_price = $custom_data ['custom_price']; } } if(!empty($product_gi_price) && !empty($product_gift_price)){ $hidden_total = $product_gift_price+$product_gi_price; } // This is necessary for WC 3.0+ if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; // Avoiding hook repetition (when using price calculations for example) if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 ) return; // Loop through cart items foreach ( $cart->get_cart() as $item ) { if(!empty($hidden_total)){ $item['data']->set_price( $hidden_total ); } } } function OCGW_support_and_rating_notice() { $screen = get_current_screen(); // print_r($screen); if( 'free_gift_wrapper' == $screen->parent_base) { ?>

Rate Us

Having Issues?

Buy me a Coffee !

If you like this plugin, buy me a coffee and help support this plugin !

Buy me a coffee !
init(); } return self::$instance; } } OCGW_front::instance(); }