Deactivate plugin on specific page - wordpress

How I deactivate "WooCommerce Product Sort and Display LITE" plugin on search results page.Because it conflicts with search results.Can you please help me?
Thanks.

add_action( 'wp_print_scripts', 'my_deregister_javascript');
function my_deregister_javascript() {
if ( !is_page('Contact') ) {//pagename
wp_deregister_script( 'WooCommerce ' );//pluginname
}
}
it detect wooommerce script except contact page.

Related

how to remove "added-to-cart notice" from every page except product archive pages?

Note: In looking for an answer to my question I came across this post but it is NOT duplicate: Remove add to cart notice and change "add to cart" button in Woocommerce the answer there gives the option to remove the notice from the entire site. I want to remove it only from the cart page and I don't want to do it with CSS.
I use external links to my site to send people directly to the shopping cart with the item already added to the cart. When doing so, the "added-to-cart notification" shows up on the cart page which I do not want.
I found this code which removes the added-to-cart notification: add_filter( 'wc_add_to_cart_message_html', '__return_false' ); but it removes the notification from all pages of my site which is not what I want.
To be more specific, I want the added-to-cart notification to show on every product archive page and nowhere else.
I tried to add a filter but it doesn't work the way I would expect it to, I tried the following two ways (and tested it with various pages to see if I could make anything work but it seems my general syntax is off because I Can't get it to do anything...
function hide_cart_notes() {
if ( ! is_archive() ) {
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
}
}
add_action( 'woocommerce', 'hide_cart_notes' );
function hide_cart_notes() {
if ( is_archive() ) {
return;
}
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
}
add_action( 'woocommerce', 'hide_cart_notes' );
when woocommerce hook starts? where it's docs? does it run at all?
these question should be answered before.
i know that WordPress parses query at parse_query hook, so i would try this
add_action('parse_query', function() {
if (!is_archive()) {
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
}
});
because is_shop(), is_archive(), is_* need query to be parsed first.

Dokan vendor add shortcode to each vendor

I have created e-commerce site with dokan.
I want to add each vendor their own livechat.
I have configured everything and just need to add short code to each vendor, but Dokan don't create new pages for vendors and I can't figure out how to do it.
I sniffed around in Dokan manuals, but can't find this specific field/place to enter shortcode
Can anybody point me into right directon?
You can use the dokan_store_profile_frame_after hook which runs only in the store page to add your shortcode. This hook is run just after the store profile. If you want to exclude certain stores, you can use the $store_user and $store_info to filter out the stores. You can add the following code the functions.php file of the theme.
add_action( 'wp_footer', function() {
$store_user = dokan()->vendor->get( get_query_var( 'author' ) );
$store_info = $store_user->get_shop_info();
if ( dokan_is_store_page() ) {
echo do_shortcode( '[contact-form-7 id="64" title="Contact form 1"]');
}
});
You can try using TalkJs. As per their website they support Dokan.
https://wordpress.org/plugins/talkjs/
https://talkjs.com/knowledge-base/article/does-talkjs-work-with-support/

Disable just the checkout option in wordpress

I have a WordPress shopping site. for the time being I want to just disable the checkout option from my site until I update all the price of the products. I tried searching over net for different solutions. but could not find any suitable solution. I am expecting to get help from here. thanks in advance. :)
remove_action( 'woocommerce_proceed_to_checkout',
'woocommerce_button_proceed_to_checkout', 20);
You can just disable all the payment options at WooCommerce->Settings page. That should refrain user from completing the order until you done with your price update.
Update:
If you want to entirely remove the button from the view, then you may need to modify the WooCommerce file. Edit the below files:
path: /woocommerce/templates/cart/cart-totals.php
//search woocommerce_proceed_to_checkout and comment the line
//this will remove the button from cart page
<?php //do_action( 'woocommerce_proceed_to_checkout' ); ?>
path: /woocommerce/includes/wc-template-functions.php
//search woocommerce_widget_shopping_cart_proceed_to_checkout and comment the line
//this will remove the checkout on the cart menu display
//echo '' . esc_html__( 'Checkout', 'woocommerce' ) . '';

De-activation of plugin dependant on another

I am writing a Woocommerce extension plugin and have managed to set it so Woocommerce must be installed and activated under the Wordpress admin pages.
If both Woocommerce and my extension plugin are activated and Woocommerce is de-activated, my plugin stays active.
How do I de-activate my plugin when Woocommerce is also de-activated?
Edit 1.
I have tried this, and other similar attempts. The hook is correct, but for some reason deactivate_plugins() does not deactivate the plugin that I am writing.
function custom_plugin() {
if (is_plugin_active('custom_plugin/custom_plugin.php')){
deactivate_plugins('custom_plugin/custom_plugin.php');
}
}
register_deactivation_hook( 'woocommerce/woocommerce.php', 'custom_plugin');
Try this below code your active theme OR custom plugin.
function custom_plugin_deactivation( $plugin, $data_value ) {
if ($plugin=="custom/custom.php")
{
deactivate_plugins('woocommerce/woocommerce.php');
}
}
add_action( 'deactivated_plugin', 'custom_plugin_deactivation', 10, 2 );

Woocommerce clear cart after payment

I'm having trouble clearing my cart after payment but I'm using Woocommerce.
I used codes and plugin from an older site (before the major update in the beginning of the year) and that doesn't seem to work now on the new updated site.
This is the functions.php
// check for clear-cart get param to clear the cart
add_action( 'init', 'woocommerce_clear_cart_url' );
function woocommerce_clear_cart_url() {
if ( isset( $_GET['clear-cart'] ) ) {
global $woocommerce;
$woocommerce->cart->empty_cart();
}
}
In the thankyou.php that appears after succesfull payment this code is in there.
<!-- clear cart after successfull payment -->
jQuery(function($) {
$.post("http://ihavetakenoutmydomain.org?clear-cart",{},function(response){
var NewCart = $(response).find('#header-cart-inner');
$('#header-cart').html(NewCart);
var NewCartItems = $(response).find('.cart-items-inner');
$('.cart-items').html(NewCartItems);
});
});
I'm using the same theme as in the older version so the header-cart-inner and header-cart are the same.
But for some reason this doesn't work with the updated Wordpress and Woocommerce.
Does anyone know what the problem might be or have another solution for clearing the cart after succesfull payment? The thankyou page should only appear after successfull payment.
I forgot one thing
If I load the link "xxx://ihavetakenoutmydomain.org?clear-cart" on my browser the cart empties. So I guess the problem would be how to activate the link on the thankyou page without redirecting away from the thankyou page.
Best regards

Resources