This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • in reply to: Filters on result page #55832
    samuelepellizzarisamuelepellizzari
    Participant

    You cannot access this content.

    in reply to: Formatting live search results #54190
    samuelepellizzarisamuelepellizzari
    Participant

    Great! Now it works as intended.

    Awesome support!

    Thanks a lot,

    Samuele

    in reply to: Formatting live search results #54186
    samuelepellizzarisamuelepellizzari
    Participant

    Hi Ernest,

    Many thanks for the quick reply.

    It makes perfect sense. Now, the class trick achieves the italic formatting, but I can’t get it to work for top and bottom margins. Please see the attached screenshots.

    What am I missing?

    Thanks again,

    Samuele

    in reply to: Show/hide results based on a datetime metafield #52990
    samuelepellizzarisamuelepellizzari
    Participant

    Hi Ernest,

    Many thanks indeed for sharing the snippet.

    I forgot to to add a detail: the plugin is set up to search through 3 different CPTs (events, products and people, i.e. the authors of our books) and works pretty well by also grouping the results. However, with your snippet activated, I get ‘events’ results only, the ones that feature such ‘start-date’ metafield.

    Shall I edit the last part as follows?
    'allow_missing' => true

    Would that be enough or do I need to add anything else?

    Thanks again,

    Samuele

    in reply to: Show/hide results based on a datetime metafield #52972
    samuelepellizzarisamuelepellizzari
    Participant

    Hi Ernest,

    Many thanks for your reply.

    Your link seems broken.

    Anyway, I would rather go for the code snippet way, since I’m not using filters for the time being.

    Have you got anything ready that I can tweak?

    Thanks,

    Samuele

    in reply to: Add to cart for a specific form #52721
    samuelepellizzarisamuelepellizzari
    Participant

    That’s good news! So I am looking forward to the upcoming release!
    Do you have any ETA?

    Thanks again.

    in reply to: Add to cart for a specific form #52718
    samuelepellizzarisamuelepellizzari
    Participant

    Hi Ernest,

    I have just tried your modified script version, to no avail: it always adds 1 item to the cart, regardless of the quantity entered.

    Am I missing anything?

    Here is the complete code:

    add_filter('asp_results', 'asp_add_to_cart_data', 10, 2);
    function asp_add_to_cart_data($results, $search_id) {
    	// Apply add to cart only to search ID = 2
    	if ( $search_id != 2 ) {
    		return $results;
    	}
    
    	$product_add_to_cart_text   = 'Add to cart';
    	$variation_add_to_cart_text = '';   // Leave it empty to not display at all
    
    	if (class_exists("WooCommerce")) {
    		$_pf = new WC_Product_Factory();
    		foreach ($results as &$r) {
    			if (
    				$r->content_type == "pagepost" &&
    				in_array($r->post_type, array("product", "product_variation"))
    			) {
    				$product = $_pf->get_product($r->id);
    				$is_variable = $product->is_type( 'variable' ) || $r->post_type == 'product_variation';
    				$link = !$is_variable ? get_permalink(wc_get_page_id('shop')) : $product->get_permalink();
    				$ajax = !$is_variable ? ' ajax_add_to_cart' : '';
    				$text = !$is_variable ? $product_add_to_cart_text : $variation_add_to_cart_text;
    				if ( empty($text) )
    					continue;
    				ob_start();
    				?>
    				<div class="woocommerce">
    					<div class="quantity">
    						<input type="number" step="1" min="1" max="" name="quantity" value="1" title="Quantity" class="input-text qty text" size="4" pattern="[0-9]*" inputmode="numeric">
    					</div>
    	<a href="<?php echo $link; ?>"
    	   class="button product_type_simple add_to_cart_button<?php echo $ajax; ?>"
    	   data-product_id="<?php echo $r->id; ?>" data-product_sku=""
    	   rel="nofollow"><?php echo $text; ?></a>
    </div>
    				<?php
    				$button = ob_get_clean();
    				$r->content .= $button;
    			}
    		}
    	}
    	return $results;
    }
    //script
    add_action('wp_footer', 'asp_add_to_cart_handler');
    function asp_add_to_cart_handler() {
        ?>
        <script>
    jQuery(function (t) {
    	if ("undefined" == typeof wc_add_to_cart_params) return !1;
    	var a = function () {
    		t(".asp_r")
    			.on("click", ".add_to_cart_button", this.onAddToCart)
    			.on("click", ".remove_from_cart_button", this.onRemoveFromCart)
    			.on("added_to_cart", this.updateButton)
    			.on("added_to_cart", this.updateCartPage)
    			.on("added_to_cart removed_from_cart", this.updateFragments);
    	};
    	(a.prototype.onAddToCart = function (a) {
    		var o = t(this);
    		if (o.is(".ajax_add_to_cart")) {
    			if (!o.attr("data-product_id")) return !0;
    			a.preventDefault(), o.removeClass("added"), o.addClass("loading");
    			var r = {};
    			r.quantity = parseInt( o.closest('.woocommerce').find('input[name=quantity]').val() || 1 );
    			t.each(o.data(), function (t, a) {
    				r[t] = a;
    			}),
    				t(document.body).trigger("adding_to_cart", [o, r]),
    				t.post(wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%", "add_to_cart"), r, function (a) {
    					a &&
    					(a.error && a.product_url
    						? (window.location = a.product_url)
    						: "yes" !== wc_add_to_cart_params.cart_redirect_after_add
    							? t(document.body).trigger("added_to_cart", [a.fragments, a.cart_hash, o])
    							: (window.location = wc_add_to_cart_params.cart_url));
    				});
    		}
    	}),
    		(a.prototype.onRemoveFromCart = function (a) {
    			var o = t(this),
    				r = o.closest(".woocommerce-mini-cart-item");
    			a.preventDefault(),
    				r.block({ message: null, overlayCSS: { opacity: 0.6 } }),
    				t
    					.post(wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%", "remove_from_cart"), { cart_item_key: o.data("cart_item_key") }, function (a) {
    						a && a.fragments ? t(document.body).trigger("removed_from_cart", [a.fragments, a.cart_hash, o]) : (window.location = o.attr("href"));
    					})
    					.fail(function () {
    						window.location = o.attr("href");
    					});
    		}),
    		(a.prototype.updateButton = function (a, o, r, e) {
    			(e = void 0 !== e && e) &&
    			(e.removeClass("loading"),
    				e.addClass("added"),
    			wc_add_to_cart_params.is_cart ||
    			0 !== e.parent().find(".added_to_cart").length ||
    			e.after(' <a href="' + wc_add_to_cart_params.cart_url + '" class="added_to_cart wc-forward" title="' + wc_add_to_cart_params.i18n_view_cart + '">' + wc_add_to_cart_params.i18n_view_cart + "</a>"),
    				t(document.body).trigger("wc_cart_button_updated", [e]));
    		}),
    		(a.prototype.updateCartPage = function () {
    			var a = window.location.toString().replace("add-to-cart", "added-to-cart");
    			t(".shop_table.cart").load(a + " .shop_table.cart:eq(0) > *", function () {
    				t(".shop_table.cart").stop(!0).css("opacity", "1").unblock(), t(document.body).trigger("cart_page_refreshed");
    			}),
    				t(".cart_totals").load(a + " .cart_totals:eq(0) > *", function () {
    					t(".cart_totals").stop(!0).css("opacity", "1").unblock(), t(document.body).trigger("cart_totals_refreshed");
    				});
    		}),
    		(a.prototype.updateFragments = function (a, o) {
    			o &&
    			(t.each(o, function (a) {
    				t(a)
    					.addClass("updating")
    					.fadeTo("400", "0.6")
    					.block({ message: null, overlayCSS: { opacity: 0.6 } });
    			}),
    				t.each(o, function (a, o) {
    					t(a).replaceWith(o), t(a).stop(!0).css("opacity", "1").unblock();
    				}),
    				t(document.body).trigger("wc_fragments_loaded"));
    		}),
    		new a();
    });
    		
        </script>
    
        <?php
    }
    in reply to: See all results #52705
    samuelepellizzarisamuelepellizzari
    Participant

    The number is indeed correct in that it corresponds to that shown on the backend. However, I thought it might be a way to take the exclusions in the Ajax Search Pro settings into account.

    Thanks for clarifying

    in reply to: See all results #52699
    samuelepellizzarisamuelepellizzari
    Participant

    I mean the number reported on the live results area.

    Please have a look at the attachment. If I search for “Correnti” (a term of the ec_collana i.e. ‘book series’ taxonomy), the term shows 12 results. However, if I click on it I am redirected to the taxonomy archive page including only 7 results (https://www.musicandbooks.edizionicurci.it/ec_collana/correnti/), which is correct.

    In fact, I excluded the digital editions (product_cat=‘digitali’) form the Ajax Search Pro settings as well as form the archive page query. Yet, they are included in the number count displayed next to the term in the live results area. For this specific ‘series’, 7 books are available in printed format + 5 are also in digital format (adding up to 12, hence the number next to the term). I’d expect that the term result count, in the live results area, indicated 7 results.

    I hope I explained myself clearly enough.

    in reply to: See all results #52697
    samuelepellizzarisamuelepellizzari
    Participant

    Great! Many thanks indeed!

    Speaking of live results, I excluded some product categories. It works, in that products belonging to those categories aren’t shown, however they are included in the result count, i.e. the number of results takes into account even the excluded categories.

    Why is that?

    Thanks again,

    Samuele

    in reply to: Add to cart for a specific form #52631
    samuelepellizzarisamuelepellizzari
    Participant

    It was still me…

    It just kind of works, in that it shows the input quantity form, however those quantities are not passed on to the cart: it’s always ‘1’ no matter the number entered in the form.

    in reply to: Add to cart for a specific form #52627
    samuelepellizzarisamuelepellizzari
    Participant

    That’s fantastic!

    And what about including the quantity input? Is the following to be changed?

    
    				<div class="woocommerce">
    					<a href="<?php echo $link; ?>"
    					   data-quantity="1"
    					   class="button product_type_simple add_to_cart_button<?php echo $ajax; ?>"
    					   data-product_id="<?php echo $r->id; ?>" data-product_sku=""
    					   rel="nofollow"><?php echo $text; ?></a>
    				</div>

    Or also the script?

    `<script>
    jQuery(function(t){if(“undefined”==typeof wc_add_to_cart_params)return!1;var a=function(){t(“.asp_r”).on(“click”,”.add_to_cart_button”,this.onAddToCart).on(“click”,”.remove_from_cart_button”,this.onRemoveFromCart).on(“added_to_cart”,this.updateButton).on(“added_to_cart”,this.updateCartPage).on(“added_to_cart removed_from_cart”,this.updateFragments)};a.prototype.onAddToCart=function(a){var o=t(this);if(o.is(“.ajax_add_to_cart”)){if(!o.attr(“data-product_id”))return!0;a.preventDefault(),o.removeClass(“added”),o.addClass(“loading”);var r={};t.each(o.data(),function(t,a){r[t]=a}),t(document.body).trigger(“adding_to_cart”,[o,r]),t.post(wc_add_to_cart_params.wc_ajax_url.toString().replace(“%%endpoint%%”,”add_to_cart”),r,function(a){a&&(a.error&&a.product_url?window.location=a.product_url:”yes”!==wc_add_to_cart_params.cart_redirect_after_add?t(document.body).trigger(“added_to_cart”,[a.fragments,a.cart_hash,o]):window.location=wc_add_to_cart_params.cart_url)})}},a.prototype.onRemoveFromCart=function(a){var o=t(this),r=o.closest(“.woocommerce-mini-cart-item”);a.preventDefault(),r.block({message:null,overlayCSS:{opacity:.6}}),t.post(wc_add_to_cart_params.wc_ajax_url.toString().replace(“%%endpoint%%”,”remove_from_cart”),{cart_item_key:o.data(“cart_item_key”)},function(a){a&&a.fragments?t(document.body).trigger(“removed_from_cart”,[a.fragments,a.cart_hash,o]):window.location=o.attr(“href”)}).fail(function(){window.location=o.attr(“href”)})},a.prototype.updateButton=function(a,o,r,e){(e=void 0!==e&&e)&&(e.removeClass(“loading”),e.addClass(“added”),wc_add_to_cart_params.is_cart||0!==e.parent().find(“.added_to_cart”).length||e.after(‘ <a href=”‘+wc_add_to_cart_params.cart_url+'” class=”added_to_cart wc-forward” title=”‘+wc_add_to_cart_params.i18n_view_cart+'”>’+wc_add_to_cart_params.i18n_view_cart+”</a>”),t(document.body).trigger(“wc_cart_button_updated”,[e]))},a.prototype.updateCartPage=function(){var a=window.location.toString().replace(“add-to-cart”,”added-to-cart”);t(“.shop_table.cart”).load(a+” .shop_table.cart:eq(0) > *”,function(){t(“.shop_table.cart”).stop(!0).css(“opacity”,”1″).unblock(),t(document.body).trigger(“cart_page_refreshed”)}),t(“.cart_totals”).load(a+” .cart_totals:eq(0) > *”,function(){t(“.cart_totals”).stop(!0).css(“opacity”,”1″).unblock(),t(document.body).trigger(“cart_totals_refreshed”)})},a.prototype.updateFragments=function(a,o){o&&(t.each(o,function(a){t(a).addClass(“updating”).fadeTo(“400″,”0.6”).block({message:null,overlayCSS:{opacity:.6}})}),t.each(o,function(a,o){t(a).replaceWith(o),t(a).stop(!0).css(“opacity”,”1″).unblock()}),t(document.body).trigger(“wc_fragments_loaded”))},new a});
    </script>`

    (the code comes for your page, of course).

    Many thanks

    in reply to: Result page incomplete #52615
    samuelepellizzarisamuelepellizzari
    Participant

    Hi Ernest,

    It works perfectly: all the results are shown.

    Now I am struggling with JetSmartFilters by Crocoblock on that search result page: it looks like they don’t get the search query properly so I can’t actually narrow the results down.

    If you might consider such compatibility for future releases, that would be great.

    Many thanks indeed for now,

    Samuele

    in reply to: Result page incomplete #52536
    samuelepellizzarisamuelepellizzari
    Participant

    Ok, I’ll try. What if I wanted ALL the result to be shown? Shall I set ‘-1’?

    in reply to: Input quantity and stock status in vertical results #52462
    samuelepellizzarisamuelepellizzari
    Participant

    Hi Ernest,

    Hope you are doing well.

    I am still struggling with input quantity for the “add to cart” button not working properly.

    In addition, is there a way to make such custom behaviours work for a specific Ajax Search Pro instance ONLY? I mean, I have three searches set for different sections of the website but I would like that only one showed the quantity/add to cart button. Is it possible?

    Many thanks for your help.

    Samuele

Viewing 15 posts - 1 through 15 (of 25 total)