Skip to content

Instantly share code, notes, and snippets.

@gitSambhal
gitSambhal / 0_reuse_code.js
Created April 5, 2017 10:28
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@gitSambhal
gitSambhal / Google Places autocomplete IONIC issue
Created August 24, 2017 06:06
It solves the issue with Google places autocomplete in IONIC which prevents clicking the result and getting the result in input field
<script>
// Assign Google autocomplete to pob
$scope.autocompletePOB = function(input){
console.log(input);
// This is a fix for Google Map Autocomplete unable to tap on result
$timeout(function() {
var predictionContainer = angular.element(document.getElementsByClassName('pac-container'));
predictionContainer.attr('data-tap-disabled', true);
predictionContainer.css('pointer-events', 'auto');
// Suggestion filter in Job listing page
function get_job_listing_taxonomy_on_ajax($query_args){
// Get the array of the taxonomy of type job_listing_category
$taxonomy_array = $query_args['tax_query'];
if(is_array($taxonomy_array)){
foreach ($taxonomy_array as $key => $ta) {
if($ta['taxonomy'] == 'job_listing_category' ){
$cat_terms = $ta['terms'];
@gitSambhal
gitSambhal / gist:aa282a357df4bfd0a65414ca608b27ad
Created May 19, 2018 06:54
This is CSP customer-specific-pricing-for-woocommerce. File "customer-specific-pricing-for-woocommerce/includes/class-wdm-apply-usp-product-price.php" to show the minimum price for listing of product. Used on https://bestlcds.com
public function showQuantityBasedPricing($price, $product)
{
global $wp_query;
$product_id = self::getProductId($product);
if ($wp_query->queried_object_id != $product_id) {
$csp_prices = self::getQuantityBasedPricing($product_id);
//print_r($csp_prices);
if(sizeof($csp_prices)){
// Fix zero price issue
@gitSambhal
gitSambhal / js-datetime-to-mysql.js
Created June 8, 2018 05:48
Convert JS date time to MySQL datetime
var formatedMysqlString = (new Date ((new Date((new Date(new Date())).toISOString() )).getTime() - ((new Date()).getTimezoneOffset()*60000))).toISOString().slice(0, 19).replace('T', ' ');
console.log( formatedMysqlString );
@gitSambhal
gitSambhal / random-invoice-number-in-woocommerce.php
Created June 10, 2018 12:37
Ramdom invoice number in woocommerce using WooCommerce Print Invoice & Delivery Note plugin.
<?php
//woocommerce-delivery-notes/includes/class-wcdn-print.php
public function get_order_invoice_number( $order_id ) {
// Custom random invoice no
$invoice_count = mt_rand(1,9999);
$invoice_prefix = mt_rand(1,9999);
$invoice_suffix = mt_rand(1,99999);
<?php
//Plugin Name:WooCommerce Print Invoice & Delivery Note
//File Path:woocommerce-delivery-notes/includes/class-wcdn-print.php
// Depended upon: https://github.com/sambhalgithub/woocommerce-sequential-order-numbers
/**
* Exit if accessed directly
*/
if ( !defined( 'ABSPATH' ) ) {
exit;
}
@gitSambhal
gitSambhal / bestlcds-eecom_mpatc.js
Created September 25, 2018 19:24
Updated JS file for Multiple Add to Cart Woocommerce plugin.
//eecom-multiple-products-add-to-cart\templates\js/eecom_mpatc.js
//Function to open loader
function open_loader()
{
jQuery('.maskloader').show();
}
//Function to close loader
function close_loader()
{
jQuery(($) => {
//Set quantity to 0 by default on product category page
if (location.href.match(/product-category/)) {
$('.input-text.qty.text').val(0);
}
//Hide the quantity dropdown
$('.quantity-cat').hide();
//Event for value change of quantity and update the dropdown value
$('.input-text.qty').on("change paste keyup", function() {
.qty.quantity-cat{
display:none;
}
.button.wc-forward{
display:inline-block;
}
.products .check {
display:none;
}