Skip to content

Instantly share code, notes, and snippets.

View tankbar's full-sized avatar

Tankbar tankbar

View GitHub Profile
@tankbar
tankbar / _buttons.scss
Created April 4, 2022 13:15
Example of SCSS for button
.btn,
.button,
button,
input[type=button],
input[type=submit] {
-webkit-appearance: none;
-moz-appearance: none;
cursor: pointer;
position: relative;
@tankbar
tankbar / functions-trustpilot.php
Created March 21, 2018 10:39
Trustpilot AFS product tracking in order confirmation mail for WooCommerce
add_action( 'woocommerce_email_after_order_table', 'add_trustpilot_afs_tracking', 20, 2 );
function add_trustpilot_afs_tracking( $order, $sent_to_admin ) {
if ( ! $sent_to_admin ) {
?>
<script type="application/json+trustpilot">
{
"recipientEmail": "<?php echo $order->billing_email; ?>",
"recipientName": "<?php echo $order->billing_first_name.' '. $order->billing_last_name; ?>",
"referenceId": "<?php echo $order->get_order_number(); ?>",
"products": [<?php
@tankbar
tankbar / _truly-centered.scss
Created February 20, 2018 22:22
Center a div/element within a div
@mixin centerer($horizontal: true, $vertical: true) {
position: absolute;
@if ($horizontal and $vertical) {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
} @else if ($horizontal) {
left: 50%;
transform: translate(-50%, 0);
} @else if ($vertical) {
@tankbar
tankbar / functions.php
Created January 24, 2018 11:33
Add 4 important product identifiers Brand, MPN, UPC, EAN, GTIN to simple and variabel products
<?php
/*
Woocommerce additional product identifier fields
Add 4 important product identifiers Brand, MPN, UPC, EAN, GTIN to simple and variabel products required for sales channels
*/
// Simple Product Hooks
// Display Fields
add_action( 'woocommerce_product_options_general_product_data', 'wpmr_custom_general_fields' );
@tankbar
tankbar / functions.php
Created December 14, 2017 10:50
WooCommerce - Add GTIN/EAN meta field for product and product variations
/**
* Adding Custom GTIN Meta Field
* Save meta data to DB
*/
// add GTIN input field
add_action('woocommerce_product_options_inventory_product_data','woocom_simple_product_gtin_field', 10, 1 );
function woocom_simple_product_gtin_field(){
global $woocommerce, $post;
$product = new WC_Product(get_the_ID());
echo '<div id="gtin_attr" class="options_group">';
@tankbar
tankbar / wc-tracking-imbox-thank-you-page
Last active December 6, 2017 14:16
ImBox Chat tracking on Thank you page
<?php
// ImBox Thank you page - Sales Confirmation page
add_action( 'woocommerce_thankyou', 'imbox_tracking_cart', 80 );
function imbox_tracking_cart( $order_id ) {
$order = new WC_Order( $order_id );
$order_nr = $order->get_order_number();
$order_email = get_user_meta( $order->user_id, 'billing_email', true );
$order_quantity = $order->get_item_count();
$order_total_shipping = $order->get_total_shipping();
@tankbar
tankbar / programs.php
Last active October 24, 2017 07:50
Tankbar Custom Post Type Registration
<?php
function register_programs_post_type(){
register_post_type('program', array(
'labels' => array(
'name' => __('Programs','tankbar'),
'singular_name' => __('Program','tankbar'),
'add_new' => __('Add program','tankbar'),
'add_new_item' => __('Add new program', 'tankbar'),
@tankbar
tankbar / wc-add-images-order-email-table.php
Created September 29, 2017 12:20 — forked from bekarice/wc-add-images-order-email-table.php
Add images to WooCommerce emails
// Edit order items table template defaults
function sww_add_wc_order_email_images( $table, $order ) {
ob_start();
$template = $plain_text ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php';
wc_get_template( $template, array(
'order' => $order,
'items' => $order->get_items(),
'show_download_links' => $show_download_links,
@tankbar
tankbar / functions.php
Created September 21, 2017 13:31
Search custom fields on WooCommerce Orders
add_filter( 'woocommerce_shop_order_search_fields', 'woocommerce_shop_order_search_order_total' );
function woocommerce_shop_order_search_order_total( $search_fields ) {
$search_fields[] = '_order_total';
return $search_fields;
}
@tankbar
tankbar / functions.php
Created September 20, 2017 09:07
Increase variations per page in WooCommerce admin tab
add_filter( 'woocommerce_admin_meta_boxes_variations_per_page', 'override_increase_variations_per_page' );
function override_increase_variations_per_page() { 
return 50; 
}