Skip to content

Instantly share code, notes, and snippets.

@peterjaap
peterjaap / fix-order-invoice-confirmation-email-item-grid.sql
Last active November 9, 2022 19:35
These queries fix the order item list in customized order/invoice email templates. Basically you need to change order to order_id and invoice to invoice_id and add area="frontend" if it's not set. Check whether you need to fix it with the SELECT queries, run the UPDATE queries to fix them.
SELECT COUNT(*) FROM email_template WHERE template_text LIKE '%order=%';
SELECT COUNT(*) FROM email_template WHERE template_text LIKE '%invoice=%';
SELECT COUNT(*) FROM email_template WHERE template_text LIKE '%sales_email_order_items%' AND template_text NOT LIKE '%area="frontend"%';
SELECT COUNT(*) FROM email_template WHERE template_text LIKE '%sales_email_order_invoice_items%' AND template_text NOT LIKE '%area="frontend"%';
UPDATE email_template SET template_text = REPLACE(template_text, "order=$order", "order_id=$order_id") WHERE template_text LIKE '%order=%';
UPDATE email_template SET template_text = REPLACE(template_text, "invoice=$invoice", "invoice_id=$invoice_id") WHERE template_text LIKE '%invoice=%';
UPDATE email_template SET template_text = REPLACE(template_text, 'handle="sales_email_order_items"', 'area="frontend" handle="sales_email_order_items"') WHERE template_text LIKE '%sales_email_order_items%' AND template_text NOT LIKE '%area="frontend"%';
UPDATE email_template SET template_text = REPLACE
@getify
getify / 1.js
Last active August 4, 2023 06:24
Converting English number sentences ("one hundred forty two point three") to numeric digits ("142.3")
convert("one hundred five"); // "105"
convert("six hundred and fifty three"); // "653"
convert("zero zero one two three"); // "123"
convert("twelve o three"); // "1203"
convert("thirteen zero nine"); // "1309"
convert("fifteen sixteen"); // "1516"
convert("fourteen ninety two"); // "1492"
convert("nineteen ten"); // "1910"
convert("twelve hundred"); // "1200"
convert("twenty three hundred"); // "2300"
@magevision
magevision / ActionCustomButton.php
Last active November 5, 2021 12:00
AddAButtonInSystemConfiguration
<?php
namespace MageVision\Blog56\Controller\Adminhtml\System\Config;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\Result\Json;
use Magento\Framework\Controller\Result\JsonFactory;
class CustomButton extends Action
@codedge
codedge / config.xml
Created January 5, 2020 16:20
Magento 2 migration files only for orders and customers
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="../../../vendor/magento/data-migration-tool/etc/config.xsd">
<steps mode="settings">
<!-- <step title="Settings Step">-->
@vasilii-b
vasilii-b / m2-php-emulate-area-code.php
Last active October 25, 2021 16:19
Shows example of usage of Magento 2 emulate area code
<?php
declare(strict_types=1);
namespace Vendor\Module\Service;
use Magento\Framework\App\Area as AppArea;
use Magento\Framework\App\State as AppState;
use Magento\Framework\DataObject;
use Magento\Framework\Exception\NoSuchEntityException;
@Spittal
Spittal / docker-compose.override.yaml
Created September 15, 2018 02:44
Docker Compose override from Springboard VR
version: '3'
services:
fpm:
volumes:
- ./:/var/www
environment:
- OPCACHE_ENABLED=0
worker:
volumes:
@Spittal
Spittal / docker-compose.yaml
Created September 15, 2018 02:43
Docker compose file from SBVR
version: '3'
services:
fpm:
image: sbvr/laravel-fpm:2.1.2
volumes:
- app:/var/www
networks:
- appnet
worker:
@hypeJunction
hypeJunction / refund.php
Last active June 26, 2023 02:58
Stripe Subscription Cancellation and Prorated Refund
<?php
class StripeSubscriptionHandler {
/**
* Cancel a Stripe subscription, optionally prorating and refunding the unused amount
*
* @param string $id Stripe Subscription ID
* @param bool $at_period_end Type of cancellation
* If set to true, will cancel the subscription at its end
@jschr
jschr / parseYouTubeUrl.js
Last active February 8, 2024 05:57
Parse YouTube URLs
import UrlPattern from 'url-pattern';
import qs from 'query-string';
// Returns YouTube Player API options from a YouTube URL.
// ie. { playlistId }
// { videoId, start, end }
// { query }
export default function parseYouTubeUrl(url) {
const [domain, querystring] = url.split('?');
const options = {};
@andrewstuart
andrewstuart / .gitlab-ci.yml
Last active June 12, 2023 17:44
One Deployment Per branch, plus CI CD, gitlab and helm setup
image: docker.mydomain.com/build/kube-go-make
variables:
DOCKER_TAG: docker.mydomain.com/myapp/home:$CI_COMMIT_REF_SLUG
DOCKER_HOST: tcp://localhost:2375
DOCKER_DRIVER: overlay
PROD_RSYNC_HOST: myprodserver.com
DOMAIN: mydomain.com
CHART_DIR: chart