Skip to content

Instantly share code, notes, and snippets.

View pejantantangguh's full-sized avatar
🎯

Herman Ng pejantantangguh

🎯
View GitHub Profile
@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 / 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 / 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 / Code.gs
Created December 18, 2018 01:33
Backup Google Sheets Daily
//Credit Reserved to :
//Abhijeet Chopra
//26 February 2016
//URL : https://gist.github.com/abhijeetchopra/99a11fb6016a70287112
//~~ Herman 18122018
function makeCopy() {
//Time stamp generation. Storing variable in formatted date as days, dd-MM-YYY
const formattedDate = Utilities.formatDate(new Date(),"GMT+10:00", "EEE, d MMM yyyy");
@pejantantangguh
pejantantangguh / woocommerce-products.sql
Created December 19, 2018 05:15 — forked from mglaman/woocommerce-products.sql
MySQL query for wooCommerce to export products.
SELECT product.ID as product_id, product.post_title as product_name, replace(product.post_content, '"', "'") as product_content, product_sku.meta_value as product_sku, product_price.meta_value as product_price, product_weight.meta_value as product_weight
FROM wp_posts as product
LEFT JOIN wp_postmeta as product_sku ON product.ID = product_sku.post_ID
LEFT JOIN wp_postmeta as product_price ON product.ID = product_price.post_ID
LEFT JOIN wp_postmeta as product_weight ON product.ID = product_weight.post_ID
WHERE (product.post_type = 'product' OR product.post_type = 'product_variation') AND product_sku.meta_key = '_sku' AND product_price.meta_key = '_price' AND product_weight.meta_key = '_weight'
ORDER BY product_id ASC
@pejantantangguh
pejantantangguh / .bash
Created January 7, 2019 10:41
Bash Line to enable Debug Log magento 2
php bin/magento config:set --lock dev/debug/debug_logging 1 && php bin/magento cache:flush
@pejantantangguh
pejantantangguh / gist:52678c11d67e2bbb1a72b52d3dac3950
Last active January 9, 2019 02:25
Install Extensions from CLI command magento 2
<!-- Thanks Fooman -->
<!-- Link URL https://github.com/magento/magento2/issues/7623#issuecomment-263995878 -->
@pejantantangguh
pejantantangguh / remove _sale_price.sql
Created March 6, 2019 23:04
SQL script to remove sale price Woocommerce
UPDATE wp_postmeta m
JOIN wp_posts p ON m.post_id=p.id
AND m.meta_key = '_sale_price'
SET m.meta_value = ''
@pejantantangguh
pejantantangguh / products_with_category.sql
Created March 19, 2019 00:28 — forked from phlbnks/products_with_category.sql
Select Product name, SKU, price and category from WordPress / WooCommerce with MySQL query
SELECT
wp_posts.post_title AS Product,
wp_postmeta1.meta_value AS SKU,
wp_postmeta2.meta_value AS Price,
GROUP_CONCAT( wp_terms.name ORDER BY wp_terms.name SEPARATOR ', ' ) AS ProductCategories
FROM wp_posts
LEFT JOIN wp_postmeta wp_postmeta1
ON wp_postmeta1.post_id = wp_posts.ID
AND wp_postmeta1.meta_key = '_sku'
LEFT JOIN wp_postmeta wp_postmeta2
@pejantantangguh
pejantantangguh / product_total.sql
Created June 11, 2019 00:40
Get total sales per product woocommerce
//Total Sales per item
// Credit to https://devin.org/woocommerce-how-to-get-total-sales-of-all-products-number/
$order_items = apply_filters( 'woocommerce_reports_top_earners_order_items', $wpdb-&gt;get_results( "
SELECT order_item_meta_2.meta_value as product_id, SUM( order_item_meta.meta_value ) as line_total FROM {$wpdb-&gt;prefix}woocommerce_order_items as order_items
LEFT JOIN {$wpdb-&gt;prefix}woocommerce_order_itemmeta as order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id
LEFT JOIN {$wpdb-&gt;prefix}woocommerce_order_itemmeta as order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id
LEFT JOIN {$wpdb-&gt;posts} AS posts ON order_items.order_id = posts.ID