Skip to content

Instantly share code, notes, and snippets.

View pejantantangguh's full-sized avatar
🎯

Herman Ng pejantantangguh

🎯
View GitHub Profile
@pejantantangguh
pejantantangguh / wc-update-bulk.php
Created June 24, 2019 05:41
Update Woocoommerce order status in bulk
add_filter ('bulk_actions-edit-shop_order','register_bulk_action');
function register_bulk_action($bulk_actions){
$bulk_actions['mark_being_processed'] = 'Mark Being Processed';
return $bulk_actions;
}
add_action ('admin_action_mark_being_processed','bulk_process_custom_status');
function bulk_process_custom_status() {
@pejantantangguh
pejantantangguh / add-wc-order-status.php
Created June 20, 2019 01:14 — forked from bekarice/add-wc-order-status.php
Add WooCommerce 2.2 Order Status
<?php // only copy if needed!
/**
* Register new status
* Tutorial: http://www.sellwithwp.com/woocommerce-custom-order-status-2/
**/
function register_awaiting_shipment_order_status() {
register_post_status( 'wc-awaiting-shipment', array(
'label' => 'Awaiting shipment',
'public' => true,
@pejantantangguh
pejantantangguh / Swapmemory.txt
Created June 12, 2019 23:20
Swap Memory ARTICLE for low memory issues
https://medium.com/@jm_c/mysql-crashing-innodb-mmap-bytes-failed-errno-12-64d5b801b2f2
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04#conclusion
@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
@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 / 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 / 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 / .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 / 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 / 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");