Skip to content

Instantly share code, notes, and snippets.

@guytzhak
guytzhak / woocommerce display sub cats.php
Created June 8, 2020 20:32
Display sub cats with "active" class for the active sub category
function mz_display_sub_cats() {
$object = get_queried_object();
$current = $object->term_id;
echo '<div class="cats cats_filters d-flex flex-nowrap">';
$class = '';
if( $object->parent > 0 ) {
@guytzhak
guytzhak / code.php
Created June 8, 2020 20:36
Woocommerce Category add to cart btns + qantity btns for variable product
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_single_add_to_cart', 10 );
/* In woocommerce/single-product/add-to-cart/variable.php file use "radio button" insead of "Select" tag
* Style the radio button with their "lable" to create "Switch" UI element.
* Something like that: */
$unique_id = twentytwenty_unique_id();
$unique_id = 'product_variations_div'. ($unique_id * rand(1, 999999));
$terms = wc_get_product_terms(
@guytzhak
guytzhak / float_quantities.php
Created June 8, 2020 20:39
Woocommerce Allow add to cart and calculate price based on float quantities
// Removes the WooCommerce filter, that is validating the quantity to be an int
remove_filter('woocommerce_stock_amount', 'intval');
// Add a filter, that validates the quantity to be a float
add_filter('woocommerce_stock_amount', 'floatval');
function statusChangeCallback(response) {
fbRegister(response);
}
jQuery('.register-button').on('click', function (e) {
e.preventDefault();
ajaxRegister();
});
if ( false === ( $customQuery = get_transient( 'projectName_related_products' ) ) ) {
$args = [
'post_type' => 'post',
];
$customQuery = new WP_Query($args);
set_transient( 'projectName_related_products', $customQuery, 99999 * HOUR_IN_SECONDS );
<?php
add_action('get_footer', function () {
wp_enqueue_script( 'selectWoo' );
wp_enqueue_style( 'select2' );
wp_enqueue_script( 'delivery-js' );
}); ?>
<section class="delivery position-relative">
<?php
$bg = get_sub_field('bg');
if( isset($bg) && !empty($bg) ) {
@guytzhak
guytzhak / iframebymozi.html
Created April 28, 2021 10:16
Iframebymozi
<iframe src="https://iqosiframe.ussl.co/" width="100%" height="200px" style="border: 0; position: fixed; left: 0; bottom: 0; width: 100%; max-height: 100%; transition: 0.15s ease-out height;" class="mozi_iframe"></iframe>
<script>
var eventMethod = window.addEventListener
? "addEventListener"
: "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod === "attachEvent"
? "onmessage"
<iframe src="https://iqosiframe2.ussl.co/" width="100%" height="200px" style="border: 0; position: fixed; left: 0; bottom: 0; width: 100%; max-height: 100%; transition: 0.15s ease-out height;" class="mozi_iframe"></iframe>
<script>
var eventMethod = window.addEventListener
? "addEventListener"
: "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod === "attachEvent"
? "onmessage"
public static function getImage( $pic, $parent_id = '', $filename = false ) {
$server = WC_LI_Settings::SERVER;
$dev = get_option( 'wc_linet_dev' );
if ( $dev == 'on' ) {
$server = WC_LI_Settings::DEV_SERVER;
}
$basePath = wp_upload_dir()['basedir'] . '/';
if( $filename ) {
function filter_clinics_index( $query ) {
if ( !is_admin() && $query->is_main_query() && is_post_type_archive( 'clinic' )){
$meta_query = $query->get('meta_query');
if( is_array($meta_query) ) {
$meta_query['order_clinic_clause'] = [
'key' => 'order_clinic',
'compare' => 'EXISTS',
'type' => 'NUMERIC'
];