Skip to content

Instantly share code, notes, and snippets.

Avatar

10Horizons 10horizons

View GitHub Profile
@10horizons
10horizons / thp-remove-upsells.php
Created May 11, 2021
Prevent upsell products from being purchased without the main product
View thp-remove-upsells.php
<?php
function thp_remove_upsells ($cart) {
$main_product_ID = 38; //CHANGE TO THE MAIN PRODUCT ID
$upsell_product_IDs = array( 39, 40 ); //CHANGE TO YOUR UPSELL PRODUCT ID's
$upsell_cart_keys = array();
$has_main_product = false;
$has_upsell = false;
@10horizons
10horizons / thp-wuppro-translation-gettext.php
Created May 5, 2021
Translate the "Added to cart" string on Woocommerce Upsell Popup PRO plugin using gettext hook.
View thp-wuppro-translation-gettext.php
<?php
function thp_wup_custom_change_strings( $translated_text, $text, $domain ) {
if ($domain == 'very-simple-woocommerce-upsell-popup') {
switch ($translated_text) {
case 'Added to Cart!' :
$translated_text = __( 'Tillagd i kundvagnen!', 'very-simple-woocommerce-upsell-popup' );
break;
}
@10horizons
10horizons / style.css
Created May 3, 2021
Woocommerce Upsell Popup PRO popup template known conflict with Flatsome theme (FIX)
View style.css
.thp-popup-container .thp-flickity-container .thp-carousel .flickity-slider>div.thp-carousel-cell {
width: 24.5% !important;
}
.thp-popup-container .thp-flickity-container .thp-carousel button.flickity-prev-next-button {
opacity: 1 !important;
}
View thp-wup-translation-using-gettext.php
<?php
function thp_wup_custom_change_strings( $translated_text, $text, $domain ) {
if ($domain == 'very-simple-woocommerce-upsell-popup') {
switch ($translated_text) {
case 'The item has been added to cart. Thank you!' :
$translated_text = __( 'Der Artikel wurde in den Warenkorb gelegt. Vielen Dank!', 'very-simple-woocommerce-upsell-popup' );
break;
case 'Would you also be interested in this item?':
@10horizons
10horizons / thp_remove_upsell.php
Last active Feb 5, 2021
Prevent upsell product from being purchased on its own
View thp_remove_upsell.php
<?php
function thp_remove_upsell ($cart) {
$main_product_ID = 38; //CHANGE TO THE MAIN PRODUCT ID
$upsell_product_ID = 39; //CHANGE TO YOUR UPSELL PRODUCT ID
$has_main_product = false;
$has_upsell = false;
foreach( $cart->get_cart() as $cart_item_key => $cart_item ) {
View thp_mult_radio_template_heading_eg2.php
<?php
function my_custom_heading ($heading) {
return 'The novel has been made into a movie! ' . $heading;
}
add_filter( 'thp_mult_radio_template_heading', 'my_custom_heading' );
View thp_mult_radio_template_heading_eg1.php
<?php
function my_custom_heading () {
return 'The novel has been made into a movie! Get the movie too?';
}
add_filter( 'thp_mult_radio_template_heading', 'my_custom_heading' );
View thp_mult_radio_template_before_radiobox.php
<?php
function my_custom_subheading () {
echo '<p><span style="font-size: small; font-weight: bold; background: orange; color: #fff; text-align: center;">Stock is limited. Order now before they\'re all gone!</span></p>';
}
add_action( 'thp_mult_radio_template_before_radiobox', 'my_custom_subheading' );
View thp_upsell_popup_scripts_enqueue.php
<?php
function my_upsell_popup_scripts_enqueue () {
if ( is_page( 13 ) ) { //CHANGE 13 TO THE ID OF YOUR PAGE!
wp_enqueue_script( 'thp-flickity-js', get_site_url().'/wp-content/plugins/woocommerce-upsell-popup-pro/js/flickity.pkgd.min.js', array('jquery'), '', false );
wp_enqueue_style( 'thp-flickity-style', get_site_url().'/wp-content/plugins/woocommerce-upsell-popup-pro/css/flickity.min.css' );
wp_enqueue_style( 'thp-flickity-style-fix', get_site_url().'/wp-content/plugins/woocommerce-upsell-popup-pro/css/fix.min.css' );
@10horizons
10horizons / template-awesome.php
Last active Jan 17, 2021
Woocommerce Upsell Popup PRO - example of custom popup template (for multiple upsell products)
View template-awesome.php
<?php
/*
Template Name: My Awesome Template
Uses Slider: No
*/