This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* --------- Adds custom fields using filters. ------ | |
The below custom fields shows various types one can use. | |
It is then displayed in the backend Order Details page and in admin and customer e-mails. | |
Checkboxes by default result only show the number 1 when clicked. I have added code so that when the a checkbox is clicked it will | |
show text such as On and Yes. Checkbox is also pre-selected. | |
Tutorial: https://easywebdesigntutorials.com/woocommerce-modifying-the-checkout-page/ | |
*/ | |
// Initial inspiration: https://businessbloomer.com/woocommerce-add-shipping-phone-checkout/ | |
// My Custom Fields |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Save the image on the server. | |
*/ | |
function save_image( $base64_img, $title ) { | |
// Upload dir. | |
$upload_dir = wp_upload_dir(); | |
$upload_path = str_replace( '/', DIRECTORY_SEPARATOR, $upload_dir['path'] ) . DIRECTORY_SEPARATOR; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const map = new Map([[1, 2], [2, 4], [4, 8]]); | |
Array.from(map) | |
// [1, 2], [2, 4], [4, 8] | |
Array.from(map.values()); | |
// [2, 4, 8] | |
Array.from(map.keys()); | |
// [1, 2, 4] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Range(start, stop, step) { | |
return Array.from({ length: (stop - start) / step + 1}, (_, i) => start + (i * step)); | |
} | |
console.log(Range(0,5,1)) // [0, 1, 2, 3, 4, 5] | |
console.log(Range(0,9,3)) // [0, 3, 6, 9] | |
console.log(Range('A'.charCodeAt(0), 'Z'.charCodeAt(0), 1).map(x => String.fromCharCode(x))); | |
// ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] |
OlderNewer