Skip to content

Instantly share code, notes, and snippets.

View UraraReika's full-sized avatar
:octocat:

Oleksandr Rudyi UraraReika

:octocat:
View GitHub Profile
@UraraReika
UraraReika / enqueue-scripts.php
Last active April 4, 2024 07:52
Enqueue International Telephone Input scripts and styles and initialise it on your input element.
<php add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_style( 'int-tel-input-style', 'https://cdn.jsdelivr.net/npm/intl-tel-input@20.3.0/build/css/intlTelInput.css' );
wp_enqueue_script( 'int-tel-input-script', 'https://cdn.jsdelivr.net/npm/intl-tel-input@20.3.0/build/js/intlTelInput.min.js', [], '20.3.0', true );
} );
@UraraReika
UraraReika / purchased-products-macro.php
Last active October 30, 2023 13:09 — forked from Crocoblock/purchased-products-macro.php
JetEngine Get purchased Woocommerce products macro
<?php
add_action( 'jet-engine/register-macros', function() {
/**
* Return purchased products IDs.
*/
class Purchased_Products_Macro extends \Jet_Engine_Base_Macros {
public function macros_tag() {
@UraraReika
UraraReika / booking-calendar-api-doc.md
Last active May 19, 2023 11:42 — forked from Crocoblock/booking-calendar-api-doc.md
JetBooking. JavaScript API documentation

Documentation for JetBooking calendar JS API

Filter jet-booking.input.config

Allows to change initial set up of booking calendar. Usage example:

window.JetPlugins.hooks.addFilter( "jet-booking.input.config", "jetBooking", ( config ) => {

	const validateDay = config.beforeShowDay;
@UraraReika
UraraReika / shipping-form.php
Created September 26, 2022 11:45
JetWooBuilder Shipping From widget compatibility with Postcodes4u plugin.
<?php
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
// Postcodes4u Options
global $pc4u_options;
$heading = isset( $settings['checkout_shipping_form_title_text'] ) && ! empty($settings['checkout_shipping_form_title_text'] ) ? $settings['checkout_shipping_form_title_text'] : 'Ship to a different address?';
?>
@UraraReika
UraraReika / jet-products-empty-products-message.php
Last active June 16, 2022 13:09
Handle Products Grid & List widgets not found message to display Elementor templates.
<?php
/**
* Use for Products List widget:
* `jet-woo-builder/shortcodes/jet-woo-products-list/not-found-message`
*
* For Wishlist widget:
* `jet-cw/wishlist/empty_text`
*
* For Compare Table widget:
* `jet-cw/compare/empty_text`
@UraraReika
UraraReika / jet-engine-wc-product-query-sale-products-macros.php
Last active June 29, 2022 11:21
Extend macros list of JetEngine listing.
<?php
add_filter( 'jet-engine/listings/macros-list', '__your_theme_prefix_get_products_on_sale' );
// Add macros to list.
function __your_theme_prefix_get_products_on_sale( $macros_list ) {
$macros_list['on_sale_products_ids'] = [
'label' => esc_html__( 'On Sale Products IDs', 'jet-engine' ),
'cb' => 'get_on_sale_products_ids',
];
@UraraReika
UraraReika / jet-woo-builder-products-not-found-message.php
Last active May 28, 2021 14:22
Handling products not found messages.
<?php
add_filter( 'jet-woo-builder/shortcodes/jet-woo-products/not-found-message', '__your_theme_prefix_set_custom_not_found_message', 10, 2 );
function __your_theme_prefix_set_custom_not_found_message( $message, $object ) {
$query = $object->query();
if ( $query->get( 'jet_smart_filters' ) === jet_smart_filters()->render->request_provider( 'raw' ) && ! $query->have_posts() ) {
$message = 'Your filter settings do not return a match. Please choose other options'; // for smart filters
} elseif ( ! $query->have_posts() ) {
@UraraReika
UraraReika / jet-woo-builder-variable-product-needed-price.php
Last active May 10, 2021 06:45
Display needed price from variable product.
<?php
add_filter( 'jet-woo-builder/template-functions/product-price', 'get_needed_price' );
function get_needed_price( $html ) {
global $product;
if ( ! is_a( $product, 'WC_Product' ) ) {
return null;
}
@UraraReika
UraraReika / jet-woo-builder-variation-swatches-in-archive-template.php
Last active May 4, 2023 17:46
Add variation swatches template inside archive template price widget
<?php
add_filter( 'jet-woo-builder/template-functions/product-price', 'get_wvs_pro_archive_variation_template', 999, 1 );
function get_wvs_pro_archive_variation_template( $html ) {
$wvs_archive_variation_template = wvs_pro_archive_variation_template();
$html .= $wvs_archive_variation_template;
return '<div class="price">' . $html . '</div>';
@UraraReika
UraraReika / jet-woo-builder-ajax-add-to-cart-with-variation-swatches.php
Last active January 21, 2024 17:17
Adding AJAX support for adding to cart
<?php
add_filter( 'jet-woo-builder/template-functions/product-add-to-cart-settings', 'wvs_pro_archive_variation_button_args', 999, 2 );
function wvs_pro_archive_variation_button_args( $args, $product ) {
$ajax_add_to_cart_enabled = 'yes' === get_option( 'woocommerce_enable_ajax_add_to_cart' );
if ( 'variable' === $product->get_type() ) {
$classname = WC_Product_Factory::get_classname_from_product_type( 'simple' );
$as_single_product = new $classname( $product->get_id() );