Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Tomasz Gregorczyk Tomasz-Silpion

💭
I may be slow to respond.
View GitHub Profile
@Tomasz-Silpion
Tomasz-Silpion / truncate_woocommerce_data.sql
Created Aug 14, 2020
Delete WooCommerce orders and customers
View truncate_woocommerce_data.sql
DELETE FROM `wp_woocommerce_order_itemmeta`;
DELETE FROM `wp_woocommerce_order_items`;
DELETE FROM `wp_comments` WHERE `comment_type` = 'order_note';
DELETE FROM `wp_postmeta` WHERE `post_id` IN (SELECT `ID` FROM `wp_posts` WHERE `post_type` = 'shop_order');
DELETE FROM `wp_posts` WHERE `post_type` = 'shop_order';
DELETE FROM `wp_users` WHERE `wp_users`.`ID` NOT IN (SELECT `meta_value` FROM `wp_postmeta` WHERE `meta_key` = '_customer_user') AND `wp_users`.ID NOT IN (SELECT DISTINCT (`post_author`) FROM `wp_posts`);
DELETE FROM `wp_usermeta` WHERE `user_id` NOT IN (SELECT `ID` FROM `wp_users`);
TRUNCATE `wp_woocommerce_order_items`;
TRUNCATE `wp_woocommerce_order_itemmeta`;
@Tomasz-Silpion
Tomasz-Silpion / payments.sql
Created Jul 20, 2016
Get all customers payment methods between range of dates from Magento database
View payments.sql
SELECT
o.grand_total AS 'Order Total',
o.created_at AS 'Payment Day',
p.method AS 'Payment Method',
CONCAT_WS(' ', o.customer_firstname, o.customer_lastname) AS 'Customer Name',
o.increment_id AS 'Order Number'
FROM sales_flat_order o
LEFT JOIN sales_flat_order_payment p ON p.entity_id = o.entity_id
WHERE (o.created_at BETWEEN '2016-01-01' AND '2016-12-31')
@Tomasz-Silpion
Tomasz-Silpion / pca.js
Last active Mar 21, 2019 — forked from thomaslorentsen/pca.js
Custom integration of post code anywhere
View pca.js
pca.on("load", function (type, id, control) {
control.listen("populate", function (address) {
console.log('here');
});
});
@Tomasz-Silpion
Tomasz-Silpion / hide_children_products.php
Created Feb 15, 2018
Hide Magento 1 products with configurable parents
View hide_children_products.php
<?php
require_once 'abstract.php';
class Hide_Children_Products extends Mage_Shell_Abstract {
/**
* Hide products having at least one configurable parent
*/
public function run()
@Tomasz-Silpion
Tomasz-Silpion / recipients.sql
Created Oct 30, 2017
Get Magento queue recipients who received outdated email
View recipients.sql
SELECT DISTINCT `recipient_email` FROM `core_email_queue` INNER JOIN `core_email_queue_recipients` ON `core_email_queue`.`message_id` = `core_email_queue_recipients`.`message_id` WHERE `processed_at` > '2017-10-30 00:00:00' AND `created_at` < '2017-10-25 00:00:00'
@Tomasz-Silpion
Tomasz-Silpion / config.php
Created Oct 24, 2017
Get element from multidimensional array by path in php
View config.php
<?php
/**
* @author Silpion <tomasz@silpion.com.pl>
*/
class Config {
protected $config = [
'a' => [
@Tomasz-Silpion
Tomasz-Silpion / nocache.conf
Last active Jun 8, 2017
Nginx config to return Magento 1 not cached images if the cached version does not exist
View nocache.conf
location ^~ /media/catalog/product/cache/ {
try_files $uri @nocache;
}
location @nocache {
rewrite ^/(media/catalog/product)/(.*/.*/.*/.*)/(.*/.*/.*) /$1/$3 redirect;
}
@Tomasz-Silpion
Tomasz-Silpion / deploy.sh
Created Jun 5, 2017
Magento2 shell script shorthand for redeployment with Snowdog front-end tools gulp usage
View deploy.sh
# Magento2 shell script shorthand for redeployment
php bin/magento setup:upgrade
cd tools && gulp clean && cd ..
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
cd tools && gulp styles && cd ..
chmod -R 775 var
chmod -R 775 pub/static
@Tomasz-Silpion
Tomasz-Silpion / wcpdf.php
Created Apr 14, 2017
Load WooCommerce PDF Invoices & Packing Slips document anywhere
View wcpdf.php
<?php
require('./wp-load.php');
$wpo_wcpdf = WPO_WCPDF();
$pdf = $wpo_wcpdf->export->get_pdf('invoice', array($order_id));
header("Content-type:application/pdf");
echo $pdf;
@Tomasz-Silpion
Tomasz-Silpion / fix_stock.php
Created Mar 10, 2017
Fix Woocommerce stock to match qty
View fix_stock.php
<?php
define('WP_USE_THEMES', false);
require('./wp-load.php');
$args = array('post_type' => 'product', 'posts_per_page' => -1);
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();
You can’t perform that action at this time.