Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
Rectified file version numbers and some minor edits.
  • Loading branch information
pinalj committed Sep 14, 2024
1 parent 35a1bec commit 85a6342
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 88 deletions.
171 changes: 85 additions & 86 deletions class-quotes-wc.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,33 @@ public function __construct() {
add_action( 'init', array( &$this, 'qwc_include_files_tracking' ) );
}

/**
* Define plugin constants.
*
* @since 2.3
*/
public function qwc_define_constants() {
if ( ! defined( 'QUOTES_TEMPLATE_PATH' ) ) {
define( 'QUOTES_TEMPLATE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/' );
}

if ( ! defined( 'QUOTES_PLUGIN_DIR' ) ) {
define( 'QUOTES_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
}

if ( ! defined( 'QUOTES_PLUGIN_URL' ) ) {
define( 'QUOTES_PLUGIN_URL', untrailingslashit( plugins_url( '/', __FILE__ ) ) );
}

if ( ! defined( 'QUOTES_PLUGIN_VERSION' ) ) {
define( 'QUOTES_PLUGIN_VERSION', $this->version );
}

if ( ! defined( 'QUOTES_PLUGIN_PATH' ) ) {
define( 'QUOTES_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
}
}

/**
* Get instance of the class.
*
Expand Down Expand Up @@ -182,33 +209,6 @@ public function qwc_update_db_check() {
update_option( 'quotes_for_wc', QUOTES_PLUGIN_VERSION );
}

/**
* Define plugin constants.
*
* @since 2.3
*/
public function qwc_define_constants() {
if ( ! defined( 'QUOTES_TEMPLATE_PATH' ) ) {
define( 'QUOTES_TEMPLATE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/' );
}

if ( ! defined( 'QUOTES_PLUGIN_DIR' ) ) {
define( 'QUOTES_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
}

if ( ! defined( 'QUOTES_PLUGIN_URL' ) ) {
define( 'QUOTES_PLUGIN_URL', untrailingslashit( plugins_url( '/', __FILE__ ) ) );
}

if ( ! defined( 'QUOTES_PLUGIN_VERSION' ) ) {
define( 'QUOTES_PLUGIN_VERSION', $this->version );
}

if ( ! defined( 'QUOTES_PLUGIN_PATH' ) ) {
define( 'QUOTES_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
}
}

/**
* Include files in the admin side.
*
Expand Down Expand Up @@ -318,7 +318,6 @@ public function qwc_change_button_text( $cart_text ) {
* @since 1.0
*/
public function qwc_css() {
$plugin_version = get_option( 'quotes_for_wc' );

if ( is_cart() || is_checkout() ) {
// Add css file only if cart contains products that require quotes.
Expand All @@ -330,22 +329,22 @@ public function qwc_css() {
if ( $_order ) {
$quote_status = $_order->get_meta( '_quote_status' );
if ( 'quote-pending' === $quote_status ) {
wp_enqueue_style( 'qwc-frontend', plugins_url( '/assets/css/qwc-frontend.css', __FILE__ ), '', $plugin_version, false );
wp_enqueue_style( 'qwc-frontend', plugins_url( '/assets/css/qwc-frontend.css', __FILE__ ), '', QUOTES_PLUGIN_VERSION, false );
}
}
}
} elseif ( ( cart_contains_quotable() && ! qwc_cart_display_price() ) || ( 'on' === get_option( 'qwc_enable_global_quote', '' ) && 'on' !== get_option( 'qwc_enable_global_prices', '' ) ) ) {
// enqueue only if Pro is not active - needed as Pro has settings which makes it possible to override the global settings.
if ( ! class_exists( 'Quotes_WC_Pro' ) ) {
wp_enqueue_style( 'qwc-frontend', plugins_url( '/assets/css/qwc-frontend.css', __FILE__ ), '', $plugin_version, false );
wp_enqueue_style( 'qwc-frontend', plugins_url( '/assets/css/qwc-frontend.css', __FILE__ ), '', QUOTES_PLUGIN_VERSION, false );
}
}
}

// Add css file only if cart contains products that require quotes.
if ( ! is_checkout_pay_page() && ! is_order_received_page() && ( ( cart_contains_quotable() && ! qwc_cart_display_price() ) || ( 'on' === get_option( 'qwc_enable_global_quote', '' ) && 'on' !== get_option( 'qwc_enable_global_prices', '' ) ) ) ) {
if ( ! class_exists( 'Quotes_WC_Pro' ) ) { // enqueue only if Pro is not active - needed as Pro has settings which makes it possible to override the global settings.
wp_enqueue_style( 'qwc-mini-cart', plugins_url( '/assets/css/qwc-shop.css', __FILE__ ), '', $plugin_version, false );
wp_enqueue_style( 'qwc-mini-cart', plugins_url( '/assets/css/qwc-shop.css', __FILE__ ), '', QUOTES_PLUGIN_VERSION, false );
}
}

Expand Down Expand Up @@ -393,7 +392,7 @@ function ( $value ) {

// Hide the prices.
if ( ! $display ) {
wp_enqueue_style( 'qwc-frontend', plugins_url( '/assets/css/qwc-frontend.css', __FILE__ ), '', $plugin_version, false );
wp_enqueue_style( 'qwc-frontend', plugins_url( '/assets/css/qwc-frontend.css', __FILE__ ), '', QUOTES_PLUGIN_VERSION, false );
}
}
}
Expand All @@ -409,67 +408,17 @@ public function qwc_thankyou_css( $order_id ) {
$quote_status = $order->get_meta( '_quote_status' );

if ( 'quote-pending' === $quote_status && ! qwc_order_display_price( $order ) ) {
$plugin_version = get_option( 'quotes_for_wc' );
wp_enqueue_style( 'qwc-frontend', plugins_url( '/assets/css/qwc-frontend.css', __FILE__ ), '', $plugin_version, false );
wp_enqueue_style( 'qwc-frontend', plugins_url( '/assets/css/qwc-frontend.css', __FILE__ ), '', QUOTES_PLUGIN_VERSION, false );
}
}

/**
* Front end JS files.
*
* @since 2.4
*/
public function qwc_load_js_frontend() {

if ( is_product() ) {
global $post;

$product_id = isset( $post->ID ) ? $post->ID : 0;

if ( $product_id > 0 ) {
$enable_quote = product_quote_enabled( $product_id );

if ( $enable_quote ) {
$plugin_version = get_option( 'quotes_for_wc' );

wp_register_script( 'qwc-product-js', plugins_url( '/assets/js/qwc-product-page.js', __FILE__ ), '', $plugin_version, array( 'in_footer' => true ) );

wp_localize_script(
'qwc-product-js',
'qwc_product_params',
array(
'product_id' => $product_id,
'quotes' => $enable_quote,
)
);
wp_enqueue_script( 'qwc-product-js' );
}
}
}
if ( is_cart() ) {
$proceed_checkout_label = '' === get_option( 'qwc_proceed_checkout_btn_label', '' ) ? __( 'Proceed to Checkout', 'quote-wc' ) : get_option( 'qwc_proceed_checkout_btn_label' );

wp_register_script( 'qwc-filter-js', plugins_url( '/build/filter.js', __FILE__ ), array( 'wp-blocks', 'wc-blocks-checkout' ), $plugin_version, array( 'in_footer' => true ) );

wp_localize_script(
'qwc-filter-js',
'filter_params',
array(
'cartContainsQuotable' => cart_contains_quotable(),
'qwcButtonText' => $proceed_checkout_label,
)
);
wp_enqueue_script( 'qwc-filter-js' );
}
}
/**
* Load JS files.
*
* @since 1.0
*/
public function qwc_load_js() {

$plugin_version = get_option( 'quotes_for_wc' );
// File to send Quote Email.
$include = false;
$order_id = 0;
Expand All @@ -487,7 +436,7 @@ public function qwc_load_js() {
}

if ( $include && $order_id > 0 ) {
wp_register_script( 'qwc-admin', plugins_url( '/assets/js/qwc-admin.js', __FILE__ ), '', $plugin_version, false );
wp_register_script( 'qwc-admin', plugins_url( '/assets/js/qwc-admin.js', __FILE__ ), '', QUOTES_PLUGIN_VERSION, false );

$ajax_url = get_admin_url() . 'admin-ajax.php';

Expand All @@ -507,7 +456,7 @@ public function qwc_load_js() {
// File to dismiss admin notice.
$notice_dismissed = get_option( 'qwc_menu_notice', '' );
if ( 'dismissed' !== $notice_dismissed ) {
wp_register_script( 'qwc-notice', plugins_url( '/assets/js/qwc-notice.js', __FILE__ ), '', $plugin_version, array( 'in_footer' => true ) );
wp_register_script( 'qwc-notice', plugins_url( '/assets/js/qwc-notice.js', __FILE__ ), '', QUOTES_PLUGIN_VERSION, array( 'in_footer' => true ) );
wp_localize_script(
'qwc-notice',
'qwc_notice_params',
Expand All @@ -519,6 +468,56 @@ public function qwc_load_js() {
}
}

/**
* Front end JS files.
*
* @since 2.4
*/
public function qwc_load_js_frontend() {

if ( is_product() ) {
global $post;

$product_id = isset( $post->ID ) ? $post->ID : 0;

if ( $product_id > 0 ) {
$enable_quote = product_quote_enabled( $product_id );

if ( $enable_quote ) {

wp_register_script( 'qwc-product-js', plugins_url( '/assets/js/qwc-product-page.js', __FILE__ ), '', QUOTES_PLUGIN_VERSION, array( 'in_footer' => true ) );

wp_localize_script(
'qwc-product-js',
'qwc_product_params',
array(
'product_id' => $product_id,
'quotes' => $enable_quote,
)
);
wp_enqueue_script( 'qwc-product-js' );

}
}
}

if ( is_cart() ) {
$proceed_checkout_label = '' === get_option( 'qwc_proceed_checkout_btn_label', '' ) ? __( 'Proceed to Checkout', 'quote-wc' ) : get_option( 'qwc_proceed_checkout_btn_label' );

wp_register_script( 'qwc-filter-js', plugins_url( '/build/filter.js', __FILE__ ), array( 'wp-blocks', 'wc-blocks-checkout' ), QUOTES_PLUGIN_VERSION, array( 'in_footer' => true ) );

wp_localize_script(
'qwc-filter-js',
'filter_params',
array(
'cartContainsQuotable' => cart_contains_quotable(),
'qwcButtonText' => $proceed_checkout_label,
)
);
wp_enqueue_script( 'qwc-filter-js' );
}
}

/**
* Ajax calls
*
Expand Down Expand Up @@ -944,7 +943,7 @@ public function woocommerce_title( $title, $id ) {
/**
* Modify the Proceed to Checkout button text when cart contains quote products.
*
* @since 2.4
* @since 2.5
*/
public function qwc_change_proceed_checkout_btn_text() {
if ( cart_contains_quotable() ) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quotes-for-woocommerce",
"version": "2.4.0",
"version": "2.5.0",
"description": "Plugin allows store owners to accept quote requests for products.",
"author": "Pinal Shah",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author TechnoVama
* @package Quotes For WooCommerce/uninstall
* @version 2.3
* @version 2.5.0
*/

if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
Expand Down

0 comments on commit 85a6342

Please sign in to comment.