Skip to content

Instantly share code, notes, and snippets.

View ben72's full-sized avatar

Ben Andersen ben72

View GitHub Profile
@ben72
ben72 / functions.php
Created April 10, 2021 07:16
WPAllExport - Copy Google Shopping feed to Facebook shopping feed after finished export
/* Copy google shopping feed to facebook shopping feed */
add_action('pmxe_after_export', 'copy_export_file', 10, 2);
function copy_export_file ($export_id, $exportObj) {
/* Only do this for my specific export with id == 36 */
if($export_id != 36) { // CHANGE 36 TO YOUR SPECIFIC export_id
return;
}
// Check whether "Secure Mode" is enabled in All Export > Settings
$is_secure_export = PMXE_Plugin::getInstance()-> getOption('secure');
if ( !$is_secure_export ) {
@ben72
ben72 / single.twig
Last active March 12, 2019 08:11
Add text for inactive cities in Ekoguiden single review page
...
<div class="col-md-8 col-xs-12 controlledPlaceWidth">
<div class="fullcontent fullwidth fleft placeDetails">
<h1 class="page-title desktop-page-title">{{post.post_title}}</h1>
{% if post %}
<div class="divlist" id= "{{post.post_name}}" >
<!-- Add text for inactive cities START -->
@ben72
ben72 / functions.php
Last active March 5, 2018 00:47
Remove specific product categories from meta section on WooCommerce product pages
/* Remove specific product categories from meta section on WooCommerce product pages */
add_filter('get_the_terms', 'exclude_specific_product_categories', 10, 3);
function exclude_specific_product_categories($terms) {
if(is_product()) {
$exclude_categories = array('Ekologiska julklappar', 'Ekologiska juklappar herr', 'Ekologiska juklappar dam', 'Ekologiska juklappar barn'); // Replace with any product categories you want to remove!
foreach($terms as $term_index => $term_object) {
if(in_array($term_object->name, $exclude_categories)) {
unset($terms[$term_index]);
}
}
@ben72
ben72 / address.js
Created January 19, 2015 19:37
Fixed Shopp bug #3195
/*!
* address.js - Description
* Copyright © 2012 by Ingenesis Limited. All rights reserved.
* Licensed under the GPLv3 {@see license.txt}
*/
(function($) {
jQuery.fn.upstate = function () {
if ( typeof regions === 'undefined' ) return;
@ben72
ben72 / gist:5224969
Created March 22, 2013 21:38
Fix me! This should issue an error on using existing email addresses in shopplugin. It should be places in functions.php. It just doesn't work now.. I get 500 (Internal Server Error).
add_filter('shopp_customer_registration','ihc_registration_data_validation');
function ihc_registration_data_validation() {
if (shopp_email_exists($_POST['email'])) {
new ShoppError(__('Email address is already registered with another Shopp customer.','Shopp'), SHOPP_ERR);
}
return $_POST;
}
@ben72
ben72 / errors.php
Last active December 15, 2015 06:19
Improved error handling for shopplugin. This is just some customizations of the errors.php file. Replace the errors.php file in your shopp templates directory.
<div class="shopp shopp-errors">
<?php $msg = shopp('storefront','errors','echo=0');
// Don't display Errors header after successful password recovery as it will confuse the customer
if(strpos($msg, __('Check your email address for instructions on resetting the password for your account.','Shopp')) !== false
or strpos($msg, __('Check your email address for your new password.','Shopp')) !== false): ?>
<ul>
<?php print $msg; ?>
<?php
// Display a password recovery link when incorrect login password entered in checkout
elseif(strpos($msg, __('The password is incorrect.','Shopp')) !== false && shopp('storefront','is-checkout')): ?>
@ben72
ben72 / errors.php
Last active December 15, 2015 05:19
Don't display any "Errors" on successful email recovery in shopplugin.
<div class="shopp shopp-errors">
<?php $msg = shopp('storefront','errors','echo=0');
if(trim($msg) == '<li>Check your email address for instructions on resetting the password for your account.</li>' ||
trim($msg) == '<li>Check your email address for your new password.</li>'): ?>
<ul>
<?php print $msg; ?>
<?php else: ?>
<h3>Errors</h3>
<ul>
<?php print $msg; ?>