Skip to content

Instantly share code, notes, and snippets.

View ventouris's full-sized avatar

Tasos Ventouris ventouris

  • Greece
View GitHub Profile
$lang = get_bloginfo("language");
if ( $lang == 'de-DE' ) {
add_action('init', 'search_base_german');
function search_base_german() {
$search_slug = 'suche'; // change slug name
$GLOBALS['wp_rewrite']->search_base = $search_slug;
}
}
@ventouris
ventouris / webpack.dev.js
Created May 23, 2017 09:35
webpack.dev.js
const helpers = require('./helpers');
const webpackMerge = require('webpack-merge'); // used to merge webpack configs
const commonConfig = require('./webpack.common.js'); // the settings that are common to prod and dev
/**
* Webpack Plugins
*/
const DefinePlugin = require('webpack/lib/DefinePlugin');
const NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin');
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
const helpers = require('./helpers');
const webpackMerge = require('webpack-merge'); // used to merge webpack configs
const commonConfig = require('./webpack.common.js'); // the settings that are common to prod and dev
/**
* Webpack Plugins
*/
const DedupePlugin = require('webpack/lib/optimize/DedupePlugin');
const DefinePlugin = require('webpack/lib/DefinePlugin');
const IgnorePlugin = require('webpack/lib/IgnorePlugin');
add_action('plugins_loaded', 'stp_pop_init');
if (!function_exists('stp_pop_init')){
function stp_pop_init() {
add_action('init', 'stp_pop_setup', 9999);
wp_register_style(
'stp_bootstrap_theme_css',
plugins_url( '/assets/css/bootstrap-theme.css', __FILE__ ),
false,
// The button to add the regular product
<a class="btn btn-addcart add_to_cart" data-count="1" data-pid="284">Add to cart</a>
// dropbox created dynamically from backend
<div class="add-on-service talktime-options hidden-box" id="talktime-options-284" style="display: block;">
<select class="form-control" id="select-extra-time-284">
<option>Please select an option</option>
<option data-attributename="pa_additional-talktime" data-slug="30mins" value="7804">30mins (+$3.00)</option>
<option data-attributename="pa_additional-talktime" data-slug="60mins" value="7805">60mins (+$6.00)</option>
</select>
getTransportations() {
let loader = this.loadingController.create({
content: 'Getting data...'
});
loader.present();
return this.wpApi.getTransportations(this.maxResults)
.then( (data) => {
if ( data.status == 200 ) {
this.transportantions = data.response.entries;
} else {
@ventouris
ventouris / js
Created September 5, 2017 12:23
Webpack production js
const helpers = require('./helpers');
const webpackMerge = require('webpack-merge'); // used to merge webpack configs
const commonConfig = require('./webpack.common.js'); // the settings that are common to prod and dev
/**
* Webpack Plugins
*/
//const DedupePlugin = require('webpack/lib/optimize/DedupePlugin');
const DefinePlugin = require('webpack/lib/DefinePlugin');
const IgnorePlugin = require('webpack/lib/IgnorePlugin');
@ventouris
ventouris / woo_update.php
Last active April 3, 2020 16:04
Add variation products programmatically on Woo
//The array has this format
//[
// {
// "name" : "T-Shirt",
// "available_attributes": [
// "size", "color"
// ],
// "variations":
// [
@ventouris
ventouris / delete-all-woocommerce-products.php
Created October 30, 2017 09:37 — forked from mikaelz/delete-all-woocommerce-products.php
Remove all WooCommerce products from database via SQL
<?php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')");
@ventouris
ventouris / functions.php
Created April 14, 2018 08:48
Free Shipping message for Woocommerce
function free_shipping_cart_notice() {
$min_amount = 100;
// Subtotal inc. Tax excl. Shipping
$current = WC()->cart->subtotal;
if ( $current < $min_amount ) {
$added_text = esc_html__('You will have FREE shipping if you add ', 'woocommerce' ) . wc_price( $min_amount - $current ) . esc_html__(' more in your order!', 'woocommerce' );
$return_to = apply_filters( 'woocommerce_continue_shopping_redirect', wc_get_raw_referer() ? wp_validate_redirect( wc_get_raw_referer(), false ) : wc_get_page_permalink( 'shop' ) );