Skip to content

Instantly share code, notes, and snippets.

View tamarazuk's full-sized avatar
👩‍💻

Tamara Zuk tamarazuk

👩‍💻
View GitHub Profile
@tamarazuk
tamarazuk / bootstrap_pagination.php
Last active March 6, 2023 12:32
WordPress Bootstrap Pagination (In active development)
<?php
/**
* Bootstrap Pagination.
*
* Echos Bootstraped paginated links (http://getbootstrap.com/components/#pagination).
*
* @since 0.0.1
*
* @param array $args {
* An array of arguments. Optional.
@tamarazuk
tamarazuk / facebook-for-wc-disable-tracking-admin-purchases.php
Created June 12, 2020 02:59
facebook-for-wc-disable-tracking-admin-purchases.php
<?php // only copy this line if needed
add_action( 'init', function() {
if ( current_user_can( 'manage_options' ) && function_exists( 'facebook_for_woocommerce' ) && isset( facebook_for_woocommerce()->get_integration()->events_tracker ) ) {
$event_tracker = facebook_for_woocommerce()->get_integration()->events_tracker;
remove_action( 'woocommerce_thankyou', [ $event_tracker, 'inject_purchase_event' ], 40 );
remove_action( 'woocommerce_payment_complete', [ $event_tracker, 'inject_purchase_event' ], 40 );
@tamarazuk
tamarazuk / sv-wc-measurement-price-calculator-translate-labels-example.php
Last active April 30, 2021 14:20
WooCommerce Measurement Price Calculator - Translate labels
<?php // only copy this line if needed
function sv_mpc_measurement_label( $label ) {
if ( 'fr_FR' === get_locale() ) {
$label = str_replace( 'Required Width', 'Largeur requise', $label );
$label = str_replace( 'Width', 'Largeur', $label );
}
return $label;
@tamarazuk
tamarazuk / wc-cart-notices-translate-messages-with-wpml.php
Last active March 12, 2021 06:38
WooCommerce Cart Notices: Translate Messages using WPML
<?php // only copy this line if needed
/**
* Register Cart Notices texts for translation with WPML when the messages are first created/updated
*/
add_filter( 'wc_cart_notices_update_fields', function( $fields ) {
if ( isset( $fields['name'] ) ) {
$slug = sanitize_title( $fields['name'] );
@tamarazuk
tamarazuk / sv_wc_charge_order_on_order_complete.php
Created September 13, 2020 05:21
Charge a WooCommerce pre-order when the associated order is set to Completed status
<?php // only copy this line if needed
/**
* Charge a WooCommerce pre-order when the associated order is set to Completed status
*
* @param int $order_id
* @param \WC_Order $order
*/
function sv_wc_charge_order_on_order_complete( $order_id, $order ) {
@tamarazuk
tamarazuk / wc-nested-category-layout-category-title-remove-parent.php
Last active July 28, 2020 13:31
WooCommerce Nested Category Layout - Remove parent category name from category title
<?php
add_filter( 'wc_nested_category_layout_category_title_html', 'wc_nested_category_layout_category_title_html', 10, 3 );
function wc_nested_category_layout_category_title_html( $title, $categories, $term ) {
$category = $categories[ count( $categories ) - 1 ];
$url = esc_attr( get_term_link( $category ) );
$link = '<a href="' . $url . '">' . wptexturize( $category->name ) . '</a>';
return sprintf( '<h2 class="wc-nested-category-layout-category-title">%s</h2>', $link );
@tamarazuk
tamarazuk / snippet-sv_facebook_for_wc_basel_theme_add_filter_for_add_to_cart_fragments.php
Last active July 4, 2020 02:50 — forked from deivamagalhaes/snippet.php
Facebook for WooCommerce: Track AddToCart event on Basel theme
<?php // only copy this line if needed
function sv_facebook_for_wc_basel_theme_add_filter_for_add_to_cart_fragments() {
// only make changes as long as Facebook for WooCommerce is installed
if ( function_exists( 'facebook_for_woocommerce' ) ) {
$events_tracker = facebook_for_woocommerce()->get_integration()->events_tracker;
$events_tracker->add_filter_for_conditional_add_to_cart_fragment();
}
@tamarazuk
tamarazuk / sv-wc-measurement-price-calculator-quantity-pattern-fix.php
Last active July 1, 2020 03:59
WooCommerce Measurement Price Calculator: Redefine the quantity input's pattern to include floating point values to fix the "Please match the requested format" HTML validation error that occurs with the Enfold theme. Please review our guide for adding custom code to WordPress Sites here: https://www.skyverge.com/blog/add-custom-code-to-wordpress/
<?php // only copy this line if needed
/**
* Filter the quantity input's pattern attribute to fix the "Please
* match the requested format" HTML validation error that occurs when using
* WooCommerce Measurement Price Calculator with certain premium themes
*
* @props to mensmaximus {@link https://github.com/mensmaximus} for the
* proposed solution
*
@tamarazuk
tamarazuk / sv-wc-csv-export-auto-export-dont-skip-exported.php
Last active April 7, 2020 16:49
WooCommerce Customer/Order/Coupon Export: Export all orders when automatically exporting (don't skip orders with exported status)
<?php // only copy this line if needed
add_filter( 'wc_customer_order_export_auto_export_new_orders_only', '__return_false' );
@tamarazuk
tamarazuk / wc-address-validation-move-postcode-lookup.php
Created November 20, 2014 22:57
WooCommerce Address Validation: Move postcode lookup fields to the top of billing and shipping fields rather than keeping them below the country field.
<?php
function wc_address_validation_move_postcode_lookup() {
wc_enqueue_js( '
( function() {
var $billingLookup = $( "#wc_address_validation_postcode_lookup_billing" );
var $shippingLookup = $( "#wc_address_validation_postcode_lookup_shipping" );
$( "div.woocommerce-billing-fields").find( "h3" ).after( $billingLookup );