Skip to content

Instantly share code, notes, and snippets.

View narodnaia's full-sized avatar

narodnaia

View GitHub Profile
@narodnaia
narodnaia / ojs-trigger-email-as-username.sql
Created June 29, 2016 06:36
PKP Open Journaling Systems - Database triggers to set user email as username
--
-- Create these triggers to allow OJS user login with his or her email instead of his username
-- (OJS controllers do not allow this feature, thus it can be implemented at database level)
--
DELIMITER $$
CREATE TRIGGER `update_username` BEFORE INSERT ON `users` FOR EACH ROW begin
set new.username = new.email;
end
$$
DELIMITER ;
@narodnaia
narodnaia / out-of-stock-notifications-per-product.php
Created June 29, 2016 06:12
Prestashop - Out of stock notification per product
<?php
/**
* Intended to run on command line. Outputs csv(;)
* Redirect output to file and attach to email, or save
* in folder.
* Minimum stock is saved (per product) as a product feature.
* You must specify feature id
*/
define('DB_HOST', 'your-host');
define('DB_USERNAME', 'your-username');
@narodnaia
narodnaia / disable-payment-methods-when-free-shipping-available.php
Last active August 11, 2016 18:46
Woocommerce - Disable all payment methods but free shipping and local pickup when free shipping is available
<?php
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
if ( 'free_shipping' === $rate->method_id ) {
$free[ $rate_id ] = $rate;
break;
}
}
foreach ( $rates as $rate_id => $rate ) {