Skip to content

Instantly share code, notes, and snippets.

@shishircse06
shishircse06 / metaConnected.js
Created May 31, 2022 07:58
metamask connected status
const checkConnection = () => {
// Check if browser is running Metamask
if (window.ethereum) {
web3 = new Web3(window.ethereum);
} else if (window.web3) {
web3 = new Web3(window.web3.currentProvider);
};
@shishircse06
shishircse06 / functions.php
Created June 25, 2020 09:14 — forked from mikejolley/functions.php
WooCommerce Disable guest checkout for certain products
<?php
// Code goes in theme functions.php or a custom plugin
add_filter( 'pre_option_woocommerce_enable_guest_checkout', 'conditional_guest_checkout_based_on_product' );
function conditional_guest_checkout_based_on_product( $value ) {
$restrict_ids = array( 1, 2, 3 ); // Replace with product ids which cannot use guest checkout
if ( WC()->cart ) {
$cart = WC()->cart->get_cart();
#!/bin/python3
import math
import os
import random
import re
import sys
#!/bin/python3
import math
import os
import random
import re
import sys
@shishircse06
shishircse06 / export_orders.php
Created March 28, 2019 11:12
Magento 2 custom order export download as csv
<?php
header("Content-type: application/csv");
$timestamp = date('d-m-Y'); //$timestamp takes the current time
$myFile = "order_export_".$timestamp.".csv"; // add timestamp to the file name
header("Content-Disposition: attachment; filename=".$myFile);
$fp = fopen('php://output', 'w');
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@shishircse06
shishircse06 / countryContinent.php
Created October 26, 2016 07:23
php country continent list
<?php
$countries = array(
"Afghanistan" => "Asia",
"Åland Islands" => "Europe",
"Albania" => "Europe",
"Algeria" => "Africa",
"American Samoa" => "Oceania",
"Andorra" => "Europe",
"Angola" => "Africa",
"Anguilla" => "North America",
Session::flash('message', 'This is a message!');
Session::flash('alert-class', 'alert-danger');
In view:
@if(Session::has('message'))
<p class="alert {{ Session::get('alert-class', 'alert-info') }}">{{ Session::get('message') }}</p>
@endif
OR:
@shishircse06
shishircse06 / selectMonth.html
Created October 27, 2015 07:43
month selection box html
<select id="month" name="month">
<option value="0">Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
@shishircse06
shishircse06 / sqlAgeLimit
Created September 17, 2015 06:37
find age from date and then query users
SELECT first_name from users where created_at >
(
select TIMESTAMPDIFF(YEAR, created_at, CURDATE())
AS age from users where id=1
)