Posted on

How to turn on debugging and log the messages in WordPress

You can enable WordPress debug without displaying the messages publicly to the site visitors.

You can enable WordPress debug in WordPress by adding

set_error_handler(function() {

        $log = " ******************** TRACE: ";

        foreach ( debug_backtrace() as $i => $item ) {

            if ( 0 === $i ) {

                $log .= " " . $item['args'][1];

            } else {
if(isset($item['file'])){
    $log .= " " . $item['file'] . ' — line ' . $item['line'];
}
            }

        }

        $log .= "***********************";

        error_log( $log );

        return true;

    }, E_ALL);

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define( 'WP_DEBUG_DISPLAY', false );


to the wp-config.php file. 

WordPress debug messages are logged without displaying to your site visitors.

You can find wp-config.php in your WordPress directory and copy and paste the 3 lines above in that file. Make sure none of the lines are repeated in the file.

You can then find the debug.log file in the WordPress wp-content directory.

Posted on

How to make the NP Quote Plugin work with page caching plugins

Depending on your caching plugin you need to exclude dynamic pages and sometimes exclude cookies from cache. The pages to exclude are the quote request, product category (archive), shop and the product page. The most common problem caused by page caching is that items which are added to the quote cart cannot be found afterwards.

WP Rocket:

/wp-admin/options-general.php?page=wprocket#advanced_cache

Never Cache URL(s)

/quote-request/(.*)

/product-category/(.*)

/shop/(.*)

/product/(.*)

Never Cache Cookies

rfqtk_wp_session_

WP Optimize: https://neahplugins.com/wp-content/uploads/word-image-148.png

If are using Pantheon:

cid:image002.png@01D80D39.80539D50

cid:image003.png@01D80D39.80539D50

You could also change the session method to PHP Sessions as an alternative method. 

Posted on

Do I need to download/reinstall the plugin after purchasing the plus version

The NP Quote Request WooCommerce Plus is an extension that you install in addition to the free version to provides a lot more options and features.

After purchasing and downloading the Plus file (RFQTK.zip) to your computer , you can install by:

1: Navigate to the plugins page in your admin area.

2: Click add new on the top of page.

cid:image001.png@01D808B2.F5CF3CF0

3: Click on upload plugin

cid:image002.png@01D808B2.F5CF3CF0

4: Click on choose file

cid:image003.png@01D808B2.F5CF3CF0

5: Browse to where you stored rfqtk.zip and select the rfqtk.zip. click open.

cid:image007.png@01D808B3.8550C1A0

6. Click install now and then activate.

cid:image008.png@01D808B3.8550C1A0

7: after activating the plugin you will see a notification

cid:image005.png@01D808B3.F3F94F00

Click on the “Click Here” and  the license key and the email you used to purchase.

cid:image010.png@01D808B3.F3F94F00

 

Posted on

Adding recipients to quote (customer and admin emails) dynamically

// Add recipients to new quotes sent to admin by adding the following to functions.php
add_filter( ‘woocommerce_email_recipient_new_rfq’, ‘new_rfq_conditional_email_recipient’, 10, 2 );

function new_rfq_conditional_email_recipient( $recipient, $order ) {

$order_id=$order->get_id() ;

$some_field_name = get_post_meta( $order_id, “some_field_name”, true );

//add recipient based on order metadata
if ($some_field_name == “abc”) {
$recipient .= “, receipt_abc@somemail.com”;
}
elseif ($some_field_name == “xyz”){
$recipient .= “, receipt_xyz@somemail . com”;
}
//add recipient based on products in the order
$order = wc_get_order( $order_id );
$items = $order->get_items();
foreach ( $items as $item_id => $item ) {
$product_id = $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id();
if ( $product_id === 1 ) {
$recipient .= “, receiptprod1@somemail.com”;
}
if ( $product_id === 2 ) {
$recipient .= “, receiptprod2@somemail.com”;
}
}

return $recipient;
}

//You can repeat the same pattern for the following emails:
//email sent to customer
add_filter( ‘woocommerce_email_recipient_customer_rfq’, ‘customer_rfq_conditional_email_recipient’, 10, 2 );
function customer_rfq_conditional_email_recipient( $recipient, $order ) {
//follow the same pattern as above
}

//proposal email sent to customer
add_filter( ‘woocommerce_email_recipient_customer_rfq_sent’, ‘customer_rfq_sent_conditional_email_recipient’, 10, 2 );
function customer_rfq_sent_conditional_email_recipient( $recipient, $order ) {
//follow the same pattern as above
}
//email sent to admin for notes
add_filter( ‘woocommerce_email_recipient_admin_note’, ‘admin_note_conditional_email_recipient’, 10, 2 );
function admin_note_conditional_email_recipient( $recipient, $order ) {
//follow the same pattern as above
}

Posted on

How to enable quote request only to selected roles in WooCommerce.

The following setup enables you to enable quote request checkout only to selected roles and allow others to buy and checkout normally.

If you need help setting it up, we can help.

Set the default setting to RFQ.

cid:image001.png@01D64977.7C2EDC30

In the roles, leave 4a blank and in 4b add the role(s) that can only request a quote. You have to create the role first.

cid:image002.png@01D64978.B1C46670

At the very bottom of the page, enter a label for people who can purchase(everybody else). This

Is the label for the cart button .

cid:image003.png@01D64978.B1C46670

In the labels section use “Add to Quote”

cid:image004.png@01D64978.B1C46670

And finally add this to the bottom of your functions.php

if(function_exists('gpls_woo_rfq_purchase_only')) {

    add_action('init', 'gpls_woo_rfq_check_role', 1);

    function gpls_woo_rfq_check_role()
    {
        $in_role = false;

        if (is_user_logged_in())
        {

            $user = wp_get_current_user();

            $user_roles = $user->roles;

            $eligible_roles = get_option('settings_gpls_woo_rfq_plus_visible_price_roles', 'no');

            $option_value_list = explode(',', $eligible_roles);

            foreach ($user_roles as $cat_id) {

                if (in_array(trim($cat_id), $option_value_list)) {
                    $in_role = true;
                }
            }
        }

        if($in_role == false){
            gpls_woo_rfq_purchase_only(); // user can see prices and purchase normally
        }


    }

}

Posted on

WooCommerce Quote Request “Normal Checkout” Setup

cid:image011.png@01D60F6E.B56913F0

cid:image012.png@01D60F6E.B56913F0

If there a few item in each category here and there that you don’t want to be “Quote Items”, then you can handle that in the individual product setup. After you have applied it by category, then navigate to the product->advanced setup and uncheck “Enable RfQ”.

 

cid:image014.png@01D60F6E.B56913F0

Handle the labels for Purchase vs Quote in labels. Make the first 4 the way it is. Read and adjust the remaining labels too.

cid:image015.png@01D60F6E.B56913F0 cid:image016.png@01D60F6E.B56913F0

Navigate to Quote Request Page tab and make sure there is a url there for Request for Quote Page URL. Last, create a menu item for quote request page so people can see their quote request page.

cid:image017.png@01D60F6E.B56913F0

Posted on

Quote Request WooCommerce – File Upload

Customers using the file upload plugin can upload files in the following screens:

  • WooCommerce checkout for both regular orders and quote requests(RFQ checkout mode).
  • Quote request (Normal checkout)
  • In the thank you section, after a quote request or order has been submitted. The uploaded file will be linked to the order / quote just submitted.
  • Product page: link the upload to an item in the cart or quote request. The uploaded file shows in the cart and the WooCommerce checkout area. In the “normal checkout” mode, the file shows up in the quote request page.

  • My account orders area: Customer can click on an order and upload a file that gets linked to that order.

In the “Respond area”: when customer responds to a quote, they can also upload a file.

Posted on

Setup products as quote items by category in quote request for WooCommerce

In the free version, you can mark an individual item as a quote item in the product advanced setup.

In the Plus version you can assign the quote status to one or more product categories in the premium version. You would create the categories in WooCommerce. Assign the products to those categories as you would normally in WooCommerce. Then you mark those categories as quote items. You can still remove an individual product from the category by going to the advanced setup of that product.

Please note: to check the check this to apply the categories before saving every time you want to apply this setting. If you want to remove all categories, then delete all the categories from the select box, check the “apply the categories before saving” checkbox and save setting.