This
$tdbLoadDataFromId = tdb_state_content::get_wp_query()->queried_object->term_id;
Seems to work.
Here is a short recording regarding the final issue: the fact the it prints everything on the top left of the screen and not on the place where the shortcode is called.
The page that I am experimenting is this one: https://carro.gr/product-category/bmw/1600-2002/1600-2002-66-77/
I think the code to provide the current product category id is this one:
if ( isset( tdb_state_content::get_wp_query()->queried_object ) ) {
$tdbLoadDataFromId = tdb_state_content::get_wp_query()->queried_object->term_id;
} else {
$term = get_term_by('slug', tdb_state_content::get_wp_query()->get('term'), tdb_state_content::get_wp_query()->get('taxonomy') );
$tdbLoadDataFromId = $term->term_id;
}
It seems to work but I am not sure if it is foul proof.
-
This reply was modified 4 years by
dimitrisv.
https://carro.gr/blog/category/blog/
You can see it in my setup too…
đ
But please ask him to provide something that will work for product categories.
Thank you!
I did manage to make it work on Categories for post items.
But it doesn’t work in Woo Product Categories.
It gave me the idea to try to get the relevant code from the theme (wp-content\plugins\td-cloud-library\includes\tdb_functions.php
wp-content\plugins\td-woo\state\td_woo_state_loader.php
) but I did not know what to pick…
Tried various combinations but with no luck so far.
Sadly it is not working for neither product categories nor post categories.
Do I have to add something else?
Thank you very much indeed! I will try it and will let you know.
It was impossible for me (or any other who will not try to reverse engineer your theme) to come up with this.
Thank you Calin!
I just did and I am looking forward to your offer.
Sadly it didn’t.
Because as we have discussed time and time again here, the cloud templates override the get_queried_object and related calls. So it returns absolutely nothing.
I will be glad if you can provide me a function that can be placed in functions.php that you have tested in Newspaper theme that echo’s the current category id if placed in a page like this:
https://carro.gr/product-category/bmw/1600-2002/1600-2002-66-77/
It should be extremely easy for you.
-
This reply was modified 4 years by
dimitrisv.
To clarify:
In my functions.php if add this code:
add_shortcode( 'category_pods', 'pods_category_shortcode' );
function pods_category_shortcode() {
$category = get_queried_object();
echo $category->term_id;
}
And add the shortcode in the theme, I do not get the current category id… (so I cannot then create the shortcode for the pods that will contain the current category id.
So the question is what do I have to do to get the current category id, of a category page in the theme.
I think that if I hide it with this code, the block will be hidden even when upsells exist. Unless you provide a different class (this class .elastislide-wrapper ) when there are no upsells, from the class you provide when there are upsells.
Does this make better sense?
If I do this it will be hidden even it has upsells. Unless you create a different (this?) class when there are no results.
Also is there a way to hide the whole block when there are no upsells?
Thank you! It worked.
However here is one new issue I noticed after this.
In the image of the product that I have the upsell, I see this weird checkbox and description in the bottom left corner.
If you go to the other product (that is not linked as upsell) the image looks fine.
-
This reply was modified 4 years by
dimitrisv.
Yes Calin, obviously it has to do with the settings. This is why I asked you so that your developers can tell you which js, css, php pages calls are involved so that I can exclude them from both cloudflare and the optimizer.
Can we have this list please?
Thank you
Here is the video: https://1drv.ms/v/s!Akul2ygARwfdh5V5kkO9ycjQcun5mw?e=23j3NK
And here are the settings in function.php to optimise the performance of woo commerce.
/** Disable Ajax Call from WooCommerce on front page and posts*/
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_cart_fragments', 11);
function dequeue_woocommerce_cart_fragments() {
if (is_front_page() || is_single() ) wp_dequeue_script('wc-cart-fragments');
}
/** Disable All WooCommerce Styles and Scripts Except Shop Pages*/
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_styles_scripts', 99 );
function dequeue_woocommerce_styles_scripts() {
if ( function_exists( 'is_woocommerce' ) ) {
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
# Styles
wp_dequeue_style( 'woocommerce-general' );
wp_dequeue_style( 'woocommerce-layout' );
wp_dequeue_style( 'woocommerce-smallscreen' );
wp_dequeue_style( 'woocommerce_frontend_styles' );
wp_dequeue_style( 'woocommerce_fancybox_styles' );
wp_dequeue_style( 'woocommerce_chosen_styles' );
wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
# Scripts
wp_dequeue_script( 'wc_price_slider' );
wp_dequeue_script( 'wc-single-product' );
wp_dequeue_script( 'wc-add-to-cart' );
wp_dequeue_script( 'wc-cart-fragments' );
wp_dequeue_script( 'wc-checkout' );
wp_dequeue_script( 'wc-add-to-cart-variation' );
wp_dequeue_script( 'wc-single-product' );
wp_dequeue_script( 'wc-cart' );
wp_dequeue_script( 'wc-chosen' );
wp_dequeue_script( 'woocommerce' );
wp_dequeue_script( 'prettyPhoto' );
wp_dequeue_script( 'prettyPhoto-init' );
wp_dequeue_script( 'jquery-blockui' );
wp_dequeue_script( 'jquery-placeholder' );
wp_dequeue_script( 'fancybox' );
wp_dequeue_script( 'jqueryui' );
}
}
}
But the behaviour is the same, regardless of them being present or not.
I did this, and it is still does not get updated. In carts that had history in them, but were abandoned, after deletion of the item the user also sees the past choices. I will post a video of the situation.
Hi Calin!
These rules
(obviously with the bottom rule also active)
seem to be working fine, but with one exception:
When you are on the cart page and you remove an item from the cart this does not show on the cart include in the menu (top right)
If we can be more specific on the files that need to be bypassed from caching it may actually work.
Thank you very much Calin! I will try it and will write in this thread if I make it work.
Just wondering if you @gurugraminfocom found a way to integrate SearchWP.
From experience, it works when you are in the search page where you do a ?s query but (obviously) it doesn’t work in the ajax based results.
SearchWP live results is based on live search:
https://searchwp.com/extensions/live-search/
Bettina it will be great if you can provide us with some documentation on how we can switch to this live-search provider.
Thank you Bettina.
Just to say that this is not happening in all cloud templates. For example in the product cloud template we added their shortcode for adding a product to wishlist and the shortcode “gets” the ID of the product without having to explicitly define it.
https://femmefatale.ecode.gr/product/azzaro-chrome-edt-200ml/
To make the question more specific:
With these two rules:
.ecode.gr/wp-json/*
.ecode.gr/wp-admin/*
Set to
Cache Level: Bypass
It seems to be working (when cache is set to ignore query string). The question is if we can make it even more specific than this.
I just realised that we can indeed set a different template per product! So the issue was sorted by allowing a template for a specific product to use the default woo product shortcode
Thank you!
If we can convince them to also take a deeper look on the woo loop element as well (i.e. adding add to cart button, enabling the integration of custom tags within each member of the loop and fixing the case with WOOF) it will be great! đ
-
This reply was modified 4 years by
dimitrisv.
Hi Calin,
One more thing about woo loop:
It is incompatible with the top selling woocommerce product filter, Woof.
Thankfully the incompatibility is only limited to the OR mode (i.e. when making multiple selections from the same choice). It will be great if your team can fix this.
For your information this is the thread.
https://pluginus.net/support/topic/cant-figure-out-the-excluded-terms-id/#postid-63019
(as you can see we spent quite a few days with lots of misunderstandings in the way due to the woo loops incompatibility (that was unknown at the time)).
For the time being I had to abandon the woo loop control because this functionality is crucial for the client and the existing attribute filter is no where near as fast as WOOF nor has functionality such as monitoring statistics (clicks per filter) etc.
I am preloading the fonts already. I tried preloading also the css e.g.
echo "<link href='https://femmefatale.ecode.gr/wp-content/plugins/td-standard-pack/Newspaper/assets/css/td_standard_pack_main.css?ver=79f8a1d02f05c15c98a62e68cd419e0b' rel='preload' as='style' crossorigin>";
echo "<link href='https://femmefatale.ecode.gr/wp-content/plugins/td-composer/legacy/Newspaper/assets/css/td_legacy_main.css?ver=381db5cebf26144e1b1ab5f0477be694' rel='preload' as='style' crossorigin>";
echo "<link href='https://femmefatale.ecode.gr/wp-content/plugins/td-standard-pack/Newspaper/assets/css/td_standard_pack_main.css?ver=79f8a1d02f05c15c98a62e68cd419e0b' rel='preload' as='style' crossorigin>";
echo "<link href='https://femmefatale.ecode.gr/wp-content/themes/Newspaper/style.css?ver=11.4' rel='preload' as='style' crossorigin>";
but still no improvement.