Skip to content

Instantly share code, notes, and snippets.

@balwantmeticulosity
balwantmeticulosity / gist:61d7cc73b4e7db1957ca880a2290a7e1
Created May 29, 2021 11:26
Woocomerce product filter by price
https://parketdoska.ua/product-category/%D0%BA%D0%BB%D0%B5%D0%BD/?min_price=50&max_price=100
https://parketdoska.ua/product-tag/3165-ru/?min_price=840&orderby=price&filter_color=beige,brown
https://parketdoska.ua/product-tag/3014-ru/
@balwantmeticulosity
balwantmeticulosity / Google-Reviews.php
Created March 24, 2021 05:34
Get Google-Reviews with PHP cURL & without API Key
<?php
/*
💬 Get Google-Reviews with PHP cURL & without API Key
=====================================================
**This is a dirty but usefull way to grab the first 8 most relevant reviews from Google with cURL and without the use of an API Key**
How to find the needed CID No:
- use: [https://pleper.com/index.php?do=tools&sdo=cid_converter]
Contributing my 2 cents
$indianStates = ['AR' => 'Arunachal Pradesh',
'AR' => 'Arunachal Pradesh',
'AS' => 'Assam',
'BR' => 'Bihar',
'CT' => 'Chhattisgarh',
'GA' => 'Goa',
'GJ' => 'Gujarat',
'HR' => 'Haryana',
@balwantmeticulosity
balwantmeticulosity / gist:87cacff14a0174db2aeb238a5835d7db
Created October 23, 2020 12:07
Magento 2 error 500 after install - Class Magento\Framework\App\ResourceConnection\Proxy does not exist
To fix the issue use this
chown -R www-data:www-data /var/www/magento2/
chmod 777 -R var
chmod 777 -R generated
chmod 777 -R app/etc
rm -rf var/cache/* var/page_cache/* var/generation/*
and
php bin/magento setup:di:compile;
@balwantmeticulosity
balwantmeticulosity / gist:7ba4842939d7a45c0c27a5da72397379
Created October 21, 2020 04:04
PHP: How to search and remove specific element from an array?
$array = array('apple', 'orange', 'strawberry', 'blueberry', 'kiwi');
1-
Use array_search to get the key and remove it with unset if found:
if (($key = array_search('strawberry', $array)) !== false) {
unset($array[$key]);
}
array_search returns false (null until PHP 4.2.0) if no item has been found.
@balwantmeticulosity
balwantmeticulosity / Mark parent navigation active when on custom post type single page Mark (highlight) custom post type parent as active item in Wordpress Navigation. When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
<?php
add_action('nav_menu_css_class', 'add_current_nav_class', 10, 2 );
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Getting the post type of the current post
add_filter( 'woocommerce_add_to_cart_fragments', 'wc_refresh_mini_cart_count');
function wc_refresh_mini_cart_count($fragments){
ob_start();
?>
<span class="cart-no mini-cart-count">
<?php echo WC()->cart->get_cart_contents_count(); ?>
</span>
<?php
$fragments['.mini-cart-count'] = ob_get_clean();
return $fragments;
@balwantmeticulosity
balwantmeticulosity / gist:771fdb8f9e78efb1d91205c02551dde8
Created July 31, 2020 09:30
Prevent the Blue highlighting of elements in Chrome when clicking
In addition to the link provided by Floremin, which clears text selection using JavaScript to "clear" the selection, you can also use pure CSS to accomplish this. The CSS is here...
.noSelect {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@balwantmeticulosity
balwantmeticulosity / woocommerce-create-order.md
Created July 26, 2020 07:26 — forked from stormwild/woocommerce-create-order.md
WooCommerce Creating Order Programmatically

WooCommerce Creating Order Programmatically

WooCommerce Create Order

creating Woocommerce order with line_item programatically

// http://stackoverflow.com/questions/26581467/creating-woocommerce-order-with-line-item-programatically
$address = array(
            'first_name' => 'Fresher',
@balwantmeticulosity
balwantmeticulosity / woo-endpoint-custom.php
Created July 26, 2020 06:07 — forked from neilgee/woo-endpoint-custom.php
WooCommerce Endpoint Order and Rename - My Account Page v2.6+
<?php
/*
Plugin Name: WooCustom My Account
Plugin URI: http://wpbeaches.com/
Description: WooCustom - add a custom area in my-account
Author: Neil Gee
Version: 1.0.0
Author URI: http://wpbeaches.com
License: GPL-2.0+