Skip to content

Instantly share code, notes, and snippets.

View sachyya's full-sized avatar
🏠
Working from home

sachyya sachyya

🏠
Working from home
View GitHub Profile
@sachyya
sachyya / sorting.php
Created July 2, 2024 04:41
Sort results by custom field
<?php
add_filter( 'cm_tsfwc_additional_search_params', 'theme_slug_alter_search_params' );
function theme_slug_alter_search_params() {
return [
'sort_by' => 'total_sales:desc', // work only with numerical fields
];
}
@sachyya
sachyya / Torontoferrari.md
Created May 31, 2024 05:23
Torontoferrari.com Setup and Editing

Site is setup as preview of the theme http://paul-themes.com/wordpress/gilber/#Home

Editing Content

Homepage

Intro section

  1. Go to Dashboard->Slides
  2. Click Edit with Elementor on Home to edit content
  3. To edit the background image, click Edit on Home, you can see the Ken Burn Background on the lower section
@sachyya
sachyya / cm-enterprise-demo.xml
Last active May 29, 2024 11:46
CM Enterprise Demo Content
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
@sachyya
sachyya / demo-content.xml
Created May 16, 2024 06:59
Simple Popup Block Demo Content
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
<?
add_filter( 'cm_tsfwc_additional_search_params', 'poynting_alter_search_params' );
function poynting_alter_search_params( $args ) {
$args['query_by'] = 'post_title,product_tags_attribute_filter'
return $args;
}
@sachyya
sachyya / gist:1945e2546b1ce6e4d60cbd67c35c57bb
Created April 24, 2024 07:38
Updated gist to filter results as per catalog visibility
<?php
// Use filter_by to filter data based on the catalog visibility
// On autocomplete bar
add_action( 'cm_tsfwc_additional_autocomplete_params', 'eolpoynt_cm_tsfwc_additional_autocomplete_params' );
function eolpoynt_cm_tsfwc_additional_autocomplete_params($args) {
$args['filter_by'] = 'catalog_visibility: search || catalog_visibility: visible';
return $args;
}
// On instant search
@sachyya
sachyya / catalog-visibility.php
Last active April 9, 2024 06:55
Search based on product catalog visibility
<?php
// Add to schema
add_filter( 'cm_tsfwc_product_fields', 'your_slug_add_stock_status_to_schema' );
function your_slug_add_stock_status_to_schema( $product_fields ) {
$product_fields[] = [ 'name' => 'catalog_visibility', 'type' => 'string', 'facet' => true ];
return $product_fields;
}
// Format data for added schema
@sachyya
sachyya / .js
Last active March 21, 2024 10:36
Pass preselected filters in Typesense search for WooCommerce
( function() {
window.addEventListener( 'load', function() {
// Typesense search for WooCommerce
// SchemaFilterName is the name of the facet defined in the schema
// tsfwInstance is the global variable passed for customization
// ts_woo_main_search is the unique identifier which can be changed from shortcode using unique_id attribute
tsfwInstance.ts_woo_main_search.helper.addDisjunctiveFacetRefinement('schemaFilterName', 'Tshirts').search();
tsfwInstance.ts_woo_main_search.helper.addDisjunctiveFacetRefinement('schemaFilterName', 'Blue').search();
} );
}() );
@sachyya
sachyya / skip-post.php
Created February 7, 2024 08:11
Hide post with Thank you term
<?php
function custom_slug_skip_post( $skip, $post ) {
if( $post->post_type == 'resource' ) {
if (has_term('Thank You', 'resource-category', $post ) || has_term('Thank You', 'resource-tag', $post ) ) {
$skip = true;
}
}
return $skip;
}
@sachyya
sachyya / customization.php
Created February 6, 2024 10:00
Typesense Customization
<?php
function cm_typesense_format_resource_category_data ( $formatted_data, $raw_data, $object_id, $schema_name ) {
if ( $schema_name == 'resource' ) {
$terms = get_the_terms( $object_id, 'resource-category' );
$resource_categories = [];
foreach ( $terms as $term ) {
// Hide the "Thank you" category.
// skip "Thank You" category from being indexed
if( $term->name != 'Thank You' ) {