Skip to content

Instantly share code, notes, and snippets.

@GreatPotato
GreatPotato / shop_ordertitem.php
Created April 12, 2022 11:35
Add event to customize product weight
<?php
public function total_weight()
{
$result = $this->om('weight')*$this->quantity;
$extras = $this->get_extra_option_objects();
foreach ($extras as $option)
$result += $option->weight*$this->quantity;
@GreatPotato
GreatPotato / quotes.ql
Last active November 11, 2021 08:44
Create a view for quotes in LS (excludes all main carts)
CREATE VIEW fiftydigital_quotes AS
SELECT DISTINCT concat(cart_name, '_', customer_id) as 'id', cart_name, customer_id
FROM shop_customer_cart_items
WHERE cart_name != 'main'
<?php
class MyModule_Module extends Core_ModuleBase
{
protected function createModuleInfo()
{
return new Core_ModuleInfo(
'MyModule',
'Whatever...',
rsync -avz /path/to/files/public_html/ username@server:/path/to/files/public_html/
@GreatPotato
GreatPotato / query.sql
Last active July 7, 2016 13:38
Mailchimp export
SELECT billing_first_name, billing_last_name, billing_email, shop_countries.name as 'country'
FROM shop_orders
LEFT JOIN shop_countries
ON shop_countries.id = shop_orders.billing_country_id
<?php
class My_Module extends Core_ModuleBase
{
public function subscribeEvents()
{
Backend::$events->addEvent('shop:onExtendCustomerModel', $this, 'extend_customer_model');
}
<?php
session_save_path('/path/to/writable/directory/inside/your/account');
ini_set('session.gc_maxlifetime', 3*60*60); // 3 hours
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 100);
ini_set('session.cookie_secure', FALSE);
ini_set('session.use_only_cookies', TRUE);
session_start();
?>
{
"head":{
"udid": "UDIDBYJAMES",
"api_key": "test123",
"api_token": "test123"
},
"body":{
"order_id": "20300",
"transaction_id": "PAY-69X87306BF709670NKUABN4Q"
}
public function process_paypal_ipn($params)
{
try
{
$order = null;
/*
* Find order and load paypal settings
*/
@GreatPotato
GreatPotato / gist:61460869f5eb03f02444
Created February 4, 2015 15:11
Convert PayPal Date/Time fields into MySQL DateTime
UPDATE transactions
SET DateTime = CAST(CONCAT(STR_TO_DATE(Date,'%d/%m/%Y'), ' ', Time) AS DateTime)