Skip to content

Instantly share code, notes, and snippets.

View pejantantangguh's full-sized avatar
🎯

Herman Ng pejantantangguh

🎯
View GitHub Profile
@pejantantangguh
pejantantangguh / index.php
Last active October 10, 2018 11:10
Multiple Store Set up in Magento 2
<?php
switch ($_SERVER['HTTP_HOST']) {
case 'www.domain1xx.com.au':
case 'domain1xx.com.au':
$params = $_SERVER; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'domain1xx';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);
break;
@pejantantangguh
pejantantangguh / Excel image grabber.vb
Created September 3, 2018 05:40
URL Path on Excel and grabbing images
Sub URLPictureInsert()
Dim Pshp As Shape
Dim xRg As Range
Dim xCol As Long
On Error Resume Next
Application.ScreenUpdating = False
'Need to update the active range sheets,
@pejantantangguh
pejantantangguh / ordernotes.php
Created July 30, 2018 06:59
Adding notes on selected shipping method woo
<?php $chosen_methods = WC()->session->get( 'chosen_shipping_methods' ) ;?>
<?php $chosen_shipping = $chosen_methods[0];?>
<?php if ($chosen_shipping == 'local_pickup:26') : ?>
<p><small>Collect your order and enjoy a 30% voucher off your next in store purchase of artwork</small></p>
<?php endif; ?>
@pejantantangguh
pejantantangguh / singleproductview.php
Created July 25, 2018 20:56
WooCommerce - Show products from current product category (when viewing a single product)
<?php
if ( is_singular('product') ) {
global $post;
// get categories
$terms = wp_get_post_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) $cats_array[] = $term->term_id;
$query_args = array( 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'id',
@pejantantangguh
pejantantangguh / Bacs default to pending Payment.php
Last active November 6, 2020 14:44
Plugins to overide Bank Transfer from on Hold to Pending Payment WooCommerce
<?php
/*
Plugin Name: bacs-to-pending-payment
Description: Change bank transfer default order status from on Hold to pending payment
Version: 1.0.0
Contributors: Suherman Ng
Author: Suherman NG
Author URI:
License: GPLv2 or later
Text Domain: CAF website
@pejantantangguh
pejantantangguh / delete-all-woocommerce-products.php
Last active December 13, 2021 15:16 — forked from mikaelz/delete-all-woocommerce-products.php
Remove all WooCommerce products from database via SQL
<?php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')");
import random
number = random.sample(range(50),20)
evenNumber = []
print (number
)
for even in number:
if even % 2 == 0:
evenNumber.append(even)
@pejantantangguh
pejantantangguh / 06. String List.py
Created November 15, 2017 05:27
If statement if input words is palindrom or not
# Strings are list
words = str(input("Type in words that you think is palindrome : "))
palindrome = words[::-1]
print (words+" "+palindrome)
if words == palindrome:
print("Your words is palindrome")
else :
print("Unfortunately this is not palindrome")
@pejantantangguh
pejantantangguh / 05. List Overlap
Created November 15, 2017 04:51
To generate random number and put it in list, cross check the value of each list and only print number that are exist in list[a] and list[b]
import random
a = random.sample(range(50),20) #Sample won't have any duplicate value
b = random.sample(range(50),20)
#See number that are generated by a
print (a)
#See number that are generated by b
print (b)
c = []
num = int(input("Please put a number to divide"))
divisorList = []
listRange = list(range(1,num+1))
for number in listRange:
if num % number == 0:
divisorList.append(number)
print (divisorList)