Skip to content

Commit

Permalink
add shop page option
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohaiminulislam1989 committed Sep 5, 2016
1 parent 4dc0d17 commit 3f2aafe
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
4 changes: 3 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: WooCommerce upcoming product, upcoming product, e-commerce, coming soon pr
Donate link: https://www.paypal.me/skshaikat
Requires at least: 3.1
Tested up to: 4.6
Stable tag: 1.3.1
Stable tag: 1.3.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -48,6 +48,8 @@ and Enjoy... :)
== Change log ==

= 1.3.2 =
* [new] Add Show / Hide option for price on shop page
* [new] Add Show / Hide option for "add to cart" button on shop page
* [fix] Fix Show all product coming soon
* [fix] Fix not showing price

Expand Down
56 changes: 33 additions & 23 deletions woocommerce-upcoming-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public function __construct()


// wup let's play option
add_action( 'template_redirect', array($this,'wup_play_ground' ) );
add_action( 'woocommerce_before_single_product', array($this,'wup_single_page_view' ) );
// wup let's play option
add_action( 'woocommerce_before_shop_loop_item', array($this,'wup_shop_page_view' ) );

// Add Discount and sales price optin in backend for addmin
add_action( 'woocommerce_product_options_pricing', array($this,'add_upcoming_options' ),10 );
Expand Down Expand Up @@ -154,28 +156,36 @@ public function admin_enqueue_scripts() {

function is_upcoming() {
global $post;
if ( get_post_meta( $post->id, '_upcoming', true ) == 'yes' ) {
if ( get_post_meta( $post->ID, '_upcoming', true ) == 'yes' ) {
return true;
} else {
return false;
}
}

function wup_play_ground()
function wup_single_page_view()
{
if ( $this->is_upcoming() ) {
if ( WC_Admin_Settings::get_option( 'wup_price_hide_single', 'no' ) == 'yes' ) {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
}
// if ( WC_Admin_Settings::get_option( 'wup_price_hide_shop', 'no' ) == 'yes' ) {
// remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
// }
if ( WC_Admin_Settings::get_option( 'wup_button_hide_single', 'no' ) == 'yes' ) {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
}
// if ( WC_Admin_Settings::get_option( 'wup_button_hide_shop', 'no' ) == 'yes' ) {
// remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
// }
}
}

function wup_shop_page_view()
{
if ( WC_Admin_Settings::get_option( 'wup_price_hide_shop', 'no' ) == 'yes' && $this->is_upcoming() ) {
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
} else {
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
}
if ( WC_Admin_Settings::get_option( 'wup_button_hide_shop', 'no' ) == 'yes' && $this->is_upcoming() ) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
} else {
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
}

Expand Down Expand Up @@ -342,13 +352,13 @@ function wup_wc_product_settings_option( $settings, $current_section )
'type' => 'checkbox'
),

// array(
// 'title' => __( 'Price Hide on Shop Page', 'wup' ),
// 'desc' => __( 'Hide price of upcoming product on shop page', 'wup' ),
// 'id' => 'wup_price_hide_shop',
// 'default' => 'no',
// 'type' => 'checkbox'
// ),
array(
'title' => __( 'Price Hide on Shop Page', 'wup' ),
'desc' => __( 'Hide price of upcoming product on shop page', 'wup' ),
'id' => 'wup_price_hide_shop',
'default' => 'no',
'type' => 'checkbox'
),

array(
'title' => __( 'Upcoming Product price label', 'wup' ),
Expand All @@ -374,13 +384,13 @@ function wup_wc_product_settings_option( $settings, $current_section )
'type' => 'checkbox'
),

// array(
// 'title' => __( '"Add to Cart" Button Hide on Shop Page', 'wup' ),
// 'desc' => __( 'Hide "Add to Cart" Button of upcoming product on shop page', 'wup' ),
// 'id' => 'wup_button_hide_shop',
// 'default' => 'no',
// 'type' => 'checkbox'
// ),
array(
'title' => __( '"Add to Cart" Button Hide on Shop Page', 'wup' ),
'desc' => __( 'Hide "Add to Cart" Button of upcoming product on shop page', 'wup' ),
'id' => 'wup_button_hide_shop',
'default' => 'no',
'type' => 'checkbox'
),

array(
'title' => __( 'Available Date Show on Single Page', 'wup' ),
Expand Down

0 comments on commit 3f2aafe

Please sign in to comment.