Skip to content

Instantly share code, notes, and snippets.

add_action( 'wcasn_form_fields', 'wcasn_custom_form_fields' );
function wcasn_custom_form_fields( $order_id ) { ?>
<label>Nota Fiscal</label>
<input type="text" name="nota_fiscal" class="wcasn-custom-fields" value="" />
<?php }
add_filter( 'wc_any_shipping_notify_shipping_company_url', 'filter_wcasn_custom_url_fields', 20, 4 );
function filter_wcasn_custom_url_fields( $url, $slug, $tracking_code, $order ) {
if ( $custom_url = $order->get_meta( '_wcasn_' . $tracking_code . '_custom_url' ) ) {
return $custom_url;
@juniorthiesen
juniorthiesen / image_swap.PHP
Created July 1, 2020 04:50
image_swap - WOOCOMMERCE
add_action('wp_footer', 'image_swap_on_hover_script');
function image_swap_on_hover_script() {
if (!is_product()) return;
?>
<script>
jQuery(document).ready(function($) {
$(window).load(function() {
$('.flexslider').flexslider({
animation: "slide",
controlNav: "thumbnails",
@juniorthiesen
juniorthiesen / snnipet.php
Last active June 25, 2020 14:35
snipet - colocar botão de rastrear
function sv_add_my_account_order_actions( $actions, $order ) {
$trackingCode = $order->get_meta('_wc_any_shipping_notify_tracking_code');
if(!empty($trackingCode)) {
$actions['help'] = array(
// adjust URL as needed
'url' => 'https://englobasistemas.com.br/sistema/gestao/Rastreamento.html?chaveNfe=' . key($trackingCode),
'name' => __( 'Rastreio', 'my-textdomain' ),
);
}
@juniorthiesen
juniorthiesen / deeplink.js
Created June 15, 2020 23:36
Deep Link Instagram
@juniorthiesen
juniorthiesen / snnipet.php
Last active July 1, 2020 20:48
entrega gratuita por classe de entrega. - remove se tiver algum sem classe
function my_wc_free_shipping_by_shipping_class( $rates, $package ) {
$shipping_class = 'entrega-gratuita'; // Slug da sua classe de entrega.
$allow_free_shipping = true;
// Verifica se todos os produtos precisam ser entregues e se possuem a class de entrega selecionada.
foreach ( $package['contents'] as $value ) {
$product = $value['data'];
if ( $product->needs_shipping() && $shipping_class !== $product->get_shipping_class() ) {
$allow_free_shipping = false;
@juniorthiesen
juniorthiesen / get_payment_method.php
Created May 20, 2020 17:27
Facebook Pixel Get Purchase Method
/**
* Triggers Purchase for payment transaction complete and for the thank you page in cases of delayed payment.
*
* @param int $order_id order identifier
*/
public function inject_purchase_event( $order_id ) {
if ( ! self::$isEnabled || $this->pixel->check_last_event( 'Purchase' ) ) {
return;
}
@juniorthiesen
juniorthiesen / utm.php
Last active May 13, 2020 15:46
Get UTM Source
<?php
// Set cookie for new users
add_action( 'init', 'set_newuser_cookie'); // Run when WordPress loads
function set_newuser_cookie() {
$cookie_value = $_SERVER["HTTP_REFERER"]; // Get URL the user came to your site for
if ( !is_admin() && !isset($_COOKIE['origin'])) { // If not an admin or if cookie doesn't exist already
setcookie( 'origin', $cookie_value, time()+3600*24*30, COOKIEPATH, COOKIE_DOMAIN, false); // Set cookie for 30 days
setcookie( 'utm_source', sanitize_key( $_GET['utm_source'] ), time() + ( 3 * 86400 ), COOKIEPATH, COOKIE_DOMAIN );
<html>
<head>
<script type="text/javascript">
setTimeout(function(){window.top.location="ifood://restaurant/COLA-AQUI-O-CODIGO} , 1000);
</script>
</head>
<body class="vsc-initialized">Conectando ao melhor restaurante...
</body>
</html>
.attachment-shop_thumbnail.size-shop_thumbnail.wp-post-image {
border-width: 1px;
border-style: solid;
border-color: #d9d9d9;
background-color: #ffffff;
}
#pass-strength-result.short {
display: none !important;
}
/**
* Order product collections by stock status, instock products first.
*/
class iWC_Orderby_Stock_Status
{
public function __construct()
{
// Check if WooCommerce is active
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
add_filter('posts_clauses', array($this, 'order_by_stock_status'), 2000);