Skip to content

Instantly share code, notes, and snippets.

@wpweb101
wpweb101 / .php
Created October 30, 2023 12:01
Adding Custom shortcode value in PDF voucher
function woo_vou_pdf_template_replace_shortcodes( $voucher_template_html, $orderid, $item_key, $items, $voucodes, $productid ) {
$prefix = WOO_VOU_META_PREFIX;
$woo_order = wc_get_order( $orderid );
// Check if order exists
if ( ! $woo_order ) {
return $voucher_template_html;
}
@wpweb101
wpweb101 / woo-vou-disable-custom-background.php
Created November 10, 2022 11:16
WooCommerce PDF Voucher - Disable custom background for storefront theme
<?php // Do not add this if it's already added in your theme
// Remove storefront custom backgroud image which appears on pdf when previewing/downloading
function remove_featured_images_from_child_theme() {
if( isset( $_GET['post_type'] ) && $_GET['post_type'] == 'woovouchers' ) {
remove_theme_support( 'custom-background' );
}
}
add_action( 'after_setup_theme', 'remove_featured_images_from_child_theme', 11 );
@wpweb101
wpweb101 / .htaccess
Created May 18, 2021 08:22
Wordpress frontend with Ajax load feature
<Files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
</Files>
@wpweb101
wpweb101 / woo-vou-rvct-german-tax-calculation.php
Created May 14, 2021 08:21
WooCommerce PDF Vouchers - Redeem Voucher on Cart Total - Code Snippet for German tax rule
<?php
/*
* Modify woocommerce tax rule for german
* Display the orginal tax without applying discount
*/
function woo_vou_german_woocommerce_calc_tax( $tax_totals, $cart ) {
$count = 1;
foreach ( $cart->cart_contents as $key => $item) {
$tax_totals['TAX-'.$count]->amount = $item['line_subtotal_tax'];
@wpweb101
wpweb101 / javascript-best-practices.js
Last active April 16, 2021 07:31
JavaScript Best Practices
var example = 0;
var result = total / input;
function myFunc() {
// Output the string to the browser console
console.log('This is console string');
if ( result ) {
@wpweb101
wpweb101 / css-best-practices.css
Last active April 16, 2021 06:51
CSS Best Practices
body {
background-image: url("example.jpg"); /* Inline commenting */
background-repeat: repeat-y;
}
/* Css for registration form*/
.registration-form {
display: block;
position: relative;
font-size: 12px;
padding: 10px 5px 10px 5px;
@wpweb101
wpweb101 / html-best-practices.html
Last active April 16, 2021 06:42
HTML Best Practices
<html>
<head>
<title>Page Title</title>
<meta charset="utf-8" />
</head>
<body>
<table>
<tr>
<td colspan="2">Example 1</td>
<td colspan="2">Example 2</td>
@wpweb101
wpweb101 / php-best-practices.php
Last active April 15, 2021 13:43
PHP Best Practices
<?php
if ( (condition1) || (condition2) ) {
// Your code
} elseif ( (condition3) && (condition4) ) {
// Your code
} else {
// Your code
}
@wpweb101
wpweb101 / javascript-iteration.js
Last active April 15, 2021 13:40
JavaScript Iteration
var j, k;
// Good example
for ( i = 0, k = getValues(); i < k; i++ ) {
// Your logic
}
// Bad example
for ( i = 0; i < getValues(); i++ ) {
// Your logic
@wpweb101
wpweb101 / javascript-declaring-variables.js
Created April 15, 2021 13:29
JavaScript Declaring variables
// Correct
var a, b, c = 'JavaScript';
// InCorrect
var a = 'JavaScript';
var b = 'JavaScript';
var c = 'JavaScript';