first commit
This commit is contained in:
115
wp-content/themes/body-relax/functions.php
Normal file
115
wp-content/themes/body-relax/functions.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Functions - Child theme custom functions
|
||||
*/
|
||||
|
||||
|
||||
/*****************************************************************************************************************
|
||||
************************** Caution: do not remove or edit anything within this section **************************/
|
||||
|
||||
/**
|
||||
* Loads the Divi parent stylesheet.
|
||||
* Do not remove this or your child theme will not work unless you include a @import rule in your child stylesheet.
|
||||
*/
|
||||
function dce_load_divi_stylesheet() {
|
||||
wp_enqueue_style( 'divi-parent-style', get_template_directory_uri() . '/style.css' );
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'dce_load_divi_stylesheet' );
|
||||
|
||||
/**
|
||||
* Makes the Divi Children Engine available for the child theme.
|
||||
* Do not remove this or you will lose all the customization capabilities created by Divi Children Engine.
|
||||
*/
|
||||
require_once('divi-children-engine/divi_children_engine.php');
|
||||
|
||||
/****************************************************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
add_filter( 'woocommerce_get_availability', 'wcs_custom_get_availability', 1, 2);
|
||||
function wcs_custom_get_availability( $availability, $_product ) {
|
||||
global $product;
|
||||
|
||||
// Change In Stock Text
|
||||
if ( $_product->is_in_stock() ) {
|
||||
$availability['availability'] = __('Duża ilość wolnych miejsc', 'woocommerce');
|
||||
}
|
||||
|
||||
// Change in Stock Text to only 1 or 2 left
|
||||
if ( $_product->is_in_stock() && $product->get_stock_quantity() == 1 ) {
|
||||
$availability['availability'] = sprintf( __('%s wolne miejsce', 'woocommerce'), $product->get_stock_quantity());
|
||||
}
|
||||
if ( $_product->is_in_stock() && $product->get_stock_quantity() >= 2 && $product->get_stock_quantity() <= 4 ) {
|
||||
$availability['availability'] = sprintf( __('%s wolne miejsca', 'woocommerce'), $product->get_stock_quantity());
|
||||
}
|
||||
if ( $_product->is_in_stock() && $product->get_stock_quantity() >= 5 && $product->get_stock_quantity() <= 21 ) {
|
||||
$availability['availability'] = sprintf( __('%s wolnych miejsc', 'woocommerce'), $product->get_stock_quantity());
|
||||
}
|
||||
if ( $_product->is_in_stock() && $product->get_stock_quantity() >= 22 && $product->get_stock_quantity() <= 24 ) {
|
||||
$availability['availability'] = sprintf( __('%s wolne miejsca', 'woocommerce'), $product->get_stock_quantity());
|
||||
}
|
||||
if ( $_product->is_in_stock() && $product->get_stock_quantity() >= 25 && $product->get_stock_quantity() <= 31 ) {
|
||||
$availability['availability'] = sprintf( __('%s wolnych miejsc', 'woocommerce'), $product->get_stock_quantity());
|
||||
}
|
||||
if ( $_product->is_in_stock() && $product->get_stock_quantity() >= 32 && $product->get_stock_quantity() <= 34 ) {
|
||||
$availability['availability'] = sprintf( __('%s wolne miejsca', 'woocommerce'), $product->get_stock_quantity());
|
||||
}
|
||||
if ( $_product->is_in_stock() && $product->get_stock_quantity() >= 35 && $product->get_stock_quantity() <= 41 ) {
|
||||
$availability['availability'] = sprintf( __('%s wolnych miejsc', 'woocommerce'), $product->get_stock_quantity());
|
||||
}
|
||||
if ( $_product->is_in_stock() && $product->get_stock_quantity() >= 42 && $product->get_stock_quantity() <= 44 ) {
|
||||
$availability['availability'] = sprintf( __('%s wolne miejsca', 'woocommerce'), $product->get_stock_quantity());
|
||||
}
|
||||
if ( $_product->is_in_stock() && $product->get_stock_quantity() >= 45 && $product->get_stock_quantity() <= 51 ) {
|
||||
$availability['availability'] = sprintf( __('%s wolnych miejsc', 'woocommerce'), $product->get_stock_quantity());
|
||||
}
|
||||
|
||||
if ( ! $_product->is_in_stock() ) {
|
||||
$availability['availability'] = __('WSZYSTKIE MIEJSCA ZOSTAŁY WYKUPIONE. <a href="mailto:szkolenia@kursymasazu.com">NAPISZ DO NAS</a> JEŚLI CHCESZ ZOSTAĆ ZAPISANY NA LISTĘ REZERWOWĄ', 'woocommerce');
|
||||
}
|
||||
|
||||
return $availability;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @snippet WooCommerce: Edit "Add to Cart" Text by Product Category
|
||||
* @how-to Get CustomizeWoo.com FREE
|
||||
* @sourcecode https://businessbloomer.com/?p=19944
|
||||
* @author Rodolfo Melogli
|
||||
* @testedwith WooCommerce 3.7.0
|
||||
*/
|
||||
|
||||
// Part 1
|
||||
// Edit Single Product Page Add to Cart Button
|
||||
|
||||
add_filter( 'woocommerce_product_single_add_to_cart_text', 'bbloomer_custom_add_to_cart_single_product' );
|
||||
|
||||
function bbloomer_custom_add_to_cart_single_product() {
|
||||
global $product;
|
||||
if ( has_term( array('webinar', 'ksiazka'), 'product_cat', $product->ID ) ) {
|
||||
return 'Kup teraz';
|
||||
} else {
|
||||
return 'Rezerwuj miejsce';
|
||||
}
|
||||
}
|
||||
|
||||
// Part 2
|
||||
// Edit Archive Pages Add to Cart Buttons
|
||||
|
||||
add_filter( 'woocommerce_product_add_to_cart_text', 'bbloomer_archive_custom_cart_button_text' );
|
||||
|
||||
function bbloomer_archive_custom_cart_button_text() {
|
||||
global $product;
|
||||
if ( has_term( array('webinar', 'ksiazka'), 'product_cat', $product->ID ) ) {
|
||||
return 'Kup teraz!';
|
||||
} else {
|
||||
return 'Rezerwuj miejsce!';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user