The popular open-source contract for web professionals by Stuff & Nonsense
- Originally published: 23rd December 2008
- Revised date: March 15th 2016
- Original post
''' | |
parsing CSV into a JSON file using SKU as primary key but also as SKU. | |
If price is 0 then it must be disabled by putting stock to 0 as well | |
If weight is 0 then it must also be put to stock 0 to avoid breaking | |
of the weights based shipping. this will process a json file which can | |
be used by wpallimport to update existing woocommerce products | |
@date 20190320 | |
@url https://gist.github.com/sinebeef/fbc1b3232709368cd3558da103e54cd7 |
# wordpress ecommerce flavoured robots.txt blocking ? filters | |
User-agent: * | |
Disallow: /*?* | |
Disallow: /blog/author/ | |
Disallow: /comments/ | |
Disallow: /login/ | |
Disallow: /feed/ | |
Disallow: /cart/ | |
Disallow: /checkout/ | |
Disallow: /wp-login.php |
/* @link https://codex.wordpress.org/Plugin_API/Action_Reference/phpmailer_init | |
*/ | |
add_action( 'phpmailer_init', 'lol_phpmailer_example', 999 ); | |
function lol_phpmailer_example( $phpmailer ) { | |
$phpmailer->isSMTP(); | |
$phpmailer->Host = 'smtp.mail.com'; | |
$phpmailer->SMTPAuth = true; // Force it to use Username and Password to authenticate | |
$phpmailer->Port = 465; | |
$phpmailer->Username = '[email protected]'; |
''' | |
CSV to JSON for Woocommerce Variation Products via wpallimport. | |
Woocommerce variable products need a parent product sku to attach to. | |
This script creates a pseudo parent from a clone of one of the children and | |
then assigns it a unique/modifed SKU and provides that modified SKU to the | |
children in the parent column/key. | |
As the source CSV is exported from a magento site there is a bit of parsing that |
/* save to log file of choice | |
*/ | |
function beef_save_log(){ | |
ob_start(); | |
echo "something"; | |
$result = ob_get_clean(); | |
$up_path = wp_upload_dir(); | |
file_put_contents( $up_path['path'] . '/lol.txt', $result, FILE_APPEND ); | |
} |
<?php | |
/** | |
* WordPress Query Comprehensive Reference | |
* Compiled by luetkemj - luetkemj.com | |
* | |
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters | |
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php | |
*/ | |
$args = array( | |
//////Author Parameters - Show posts associated with certain author. |
/* Modify $query via pre_get_posts to change sorting | |
* of certain archive pages. | |
* @link https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts | |
*/ | |
add_action( 'pre_get_posts', 'custom_query_vars' ); | |
function custom_query_vars( $query ) { | |
if ( !is_admin() && $query->is_main_query() ) { | |
if ( is_product_category('cleats') ) { | |
$query->set( 'posts_per_page', '-1' ); |
//https://wordpress.stackexchange.com/questions/291855/how-to-get-current-url-in-contact-form-7 | |
//You can use cf7 hidden field shortcodes + get parameters: https://contactform7.com/hidden-field/ https://contactform7.com/getting-default-values-from-the-context/ | |
//In the mail form I use such shortcodes to get these slugs | |
[hidden utm_source default:get] | |
[hidden utm_medium default:get] | |
[hidden utm_campaign default:get] | |
[hidden utm_content default:get] |
(function ($) { | |
$(document).ready(function () { | |
console.log("ready!"); | |
$('.left').on("click", function (e) { | |
e.preventDefault(); | |
console.log('moo'); | |
}); | |
}); | |
})(jQuery); |