Skip to content

Instantly share code, notes, and snippets.

View senadir's full-sized avatar

Seghir Nadir senadir

View GitHub Profile
@senadir
senadir / frontend.js
Last active April 8, 2024 12:31
Add a field to Checkout block that can adds a fee to an order realtime.
let selectedValue = null;
wp.data.subscribe( () => {
// This is only needed for fields registered in Contact or Additional, address fields are always pushed and you can use other hooks.
const additionalFields = wp.data
.select( 'wc/store/checkout' )
.getAdditionalFields();
// Use the same id you used to register your field.
const donationAmount = additionalFields[ 'my-plugin/donation' ];
<?php
/**
* A class to add support for webhooks endpoints.
*/
class Yalidine_Shipping_Webhooks {
/**
* The processing statuses.
*
assets/js/base/components/cart-checkout/address-form/index.js -> assets/js/base/components/text-input/index.js -> assets/js/base/components/text-input/validated.js -> assets/js/base/context/index.js -> assets/js/base/context/cart-checkout/index.js -> assets/js/base/context/cart-checkout/payment-methods/index.js -> assets/js/base/context/cart-checkout/payment-methods/payment-method-data-context.js -> assets/js/base/hooks/index.js -> assets/js/base/hooks/payment-methods/index.js -> assets/js/base/hooks/payment-methods/use-payment-method-interface.js -> assets/js/base/components/cart-checkout/index.js -> assets/js/base/components/cart-checkout/address-form/index.js
assets/js/base/components/cart-checkout/index.js -> assets/js/base/components/cart-checkout/address-form/index.js -> assets/js/base/components/text-input/index.js -> assets/js/base/components/text-input/validated.js -> assets/js/base/context/index.js -> assets/js/base/context/cart-checkout/index.js -> assets/js/base/context/cart-checkout/paym
const { uniqBy } = require("lodash");
const glob = require("glob-promise");
const fs = require("fs").promises;
glob("episodes-data/*.json")
.then((files) => {
// read the folder or folders if you want: example json/**/*.json
return Promise.all(
files.map((file) => {
return fs
.readFile(file, "utf8")
[
{
"title": "The One Where Monica Gets a Roommate (Pilot)",
"number": "1",
"image": "https://occ-0-784-778.1.nflxso.net/dnm/api/v6/9pS1daC2n6UGc3dUogvWIPMR_OU/AAAABYNxZy-KPW08N_V_2cnzjfvZS5IoQwEq8UlA1afJW0kqOp4J6I6L0uEQtPQlW147Vi9vE3u5jBGuU_CxWcXKrdFZGf-3AYUMuiiBOHVFMIQ0MuFi.webp?r=42d",
"plot": "Rachel runs from her wedding and meets the friends in the coffee place. Ross is depressed about his divorce but he still has a crush on Rachel.",
"link": "https://www.netflix.com/watch/70273997",
"season": "1"
},
{
// only frontend block files
const b25 = require('./2.5.size-gzip.json').results;
const b26 = require('./2.6.size-gzip.json').results;
// all files.
const b25All = require('./blocks-2.5-all.json').results;
const b26All = require('./blocks-2.6-all.json').results;
const bytes = require('bytes');
const tablemark = require('tablemark')
@import url( 'https://fonts.googleapis.com/css2?family=Source+Sans+Pro&display=swap' );
body {
width: 100vw;
height: 100vh;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
font-family: 'Source Sans Pro', sans-serif;
}
const fs = require('fs').promises;
const { readFileSync } = require('fs');
const gzipSize = require('gzip-size');
const { filesize } = require('humanize');
const wpDeps = require('./wp-deps.json');
const filesFolder = './files'
const handleExternal = (dep, ext) => {
const wcHandleMap = {
'polyfill': 'wp-polyfill',
{
"active-filters-frontend.js": [
[ "react-dom", 36702, "35.84 KB" ],
[ "wp-polyfill", 33765, "32.97 KB" ],
[ "lodash", 24343, "23.77 KB" ],
[ "wp-data", 8654, "8.45 KB" ],
[ "wc-blocks-data-store", 7080, "6.91 KB" ],
[ "wp-compose", 6699, "6.54 KB" ],
[ "react", 5177, "5.06 KB" ],
[ "wp-url", 4679, "4.57 KB" ],
--- a/assets/js/blocks/cart-checkout/cart/full-cart/cart-line-item-row.js
+++ b/assets/js/blocks/cart-checkout/cart/full-cart/cart-line-item-row.js
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
-import { RawHTML } from '@wordpress/element';
+import { RawHTML, useState, useEffect } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import PropTypes from 'prop-types';