Skip to content

Instantly share code, notes, and snippets.

View 10horizons's full-sized avatar

10Horizons 10horizons

View GitHub Profile
@10horizons
10horizons / get-woocommerce-current-product-category-in-single-product-page.php
Last active May 22, 2019 13:16
Check for current product category in single product page (Woocommerce)
<?php
/*
URL: https://wproot.dev/blog/get-woocommerce-current-product-category-single-product-page/
*/
if ( has_term( 'tshirts', 'product_cat' ) ) //product category is tshirts
{
$flatrate = '10.00';
}
elseif ( has_term( 'hoodies', 'product_cat' ) ) //product category is hoodies
@10horizons
10horizons / wc-display-all-products-eligible-for-coupons.php
Last active May 22, 2019 13:17
Display all Woocommerce products eligible for coupons created with Woocommerce
<?php
/*
URL: https://wproot.dev/blog/woocommerce-display-all-products-eligible-for-coupons/
*/
$args = array(
'posts_per_page' => -1, //show all posts
'post_type' => 'shop_coupon', //custom post type
'post_status' => 'publish', //published coupons only
);
@10horizons
10horizons / template-awesome.php
Last active January 17, 2021 23:56
Woocommerce Upsell Popup PRO - example of custom popup template (for multiple upsell products)
<?php
/*
Template Name: My Awesome Template
Uses Slider: No
*/
<?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' );
<?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' );
<?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' );
@10horizons
10horizons / thp_remove_upsell.php
Last active February 5, 2021 08:45
Prevent upsell product from being purchased on its own
<?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 ) {
<?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 / style.css
Created May 3, 2021 23:57
Woocommerce Upsell Popup PRO popup template known conflict with Flatsome theme (FIX)
.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;
}
@10horizons
10horizons / thp-wuppro-translation-gettext.php
Created May 5, 2021 18:52
Translate the "Added to cart" string on Woocommerce Upsell Popup PRO plugin using gettext hook.
<?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;
}