Empty any cart with woocommerce product after 12 hours
add_action( 'woocommerce_thankyou', 'wc_empty_cart' );
function wc_empty_cart( $order_id ){
global $woocommerce;
$woocommerce->cart->empty_cart();
}
All generations.
add_action( 'woocommerce_thankyou', 'wc_empty_cart' );
function wc_empty_cart( $order_id ){
global $woocommerce;
$woocommerce->cart->empty_cart();
}
Script
CouponTrans(context).trans('overflow_coupon_desc',
{
"coupon_code": coupon.code,
"coupon_name": coupon.name,
"coupon_discount": getCurrencyFormatted(coupon.discount),
"coupon_min_cart": getCurrencyFormatted(coupon.min_cart),
"coupon_max_cart": getCurrencyFormatted(coupon.max_cart),
"coupon_min_quantity": coupon.min_quantity,
"coupon_max_quantity": coupon.max_quantity,
"coupon_min_product_quantity": coupon.min_product_quantity,
"coupon_max_product_quantity": coupon.max_product_quantity,
function wcfmmp_store_untitled_seo_fix( $title ) {
global $WCFM, $WCFMmp, $post;
if( isset( $post->post_type ) && 'wcfm_stores' === $post->post_type && 'wcfmmp_stores' === $post->post_name ) {
$store_user = get_post_meta( $post->ID, '_wcfm_store_owner', true );
$store_info = $WCFMmp->wcfmmp_vendor->get_vendor_store_info( $store_user );
$title = $store_info['store_name'];
}
return $title;
}
add_filter( 'the_title', 'wcfmmp_store_untitled_seo_fix', 99 );
String(format: "%.2f", price)
Scaffold(
appBar: AppBar(
title: Text('My Fancy Dress'),
),
body: SingleChildScrollView(
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('We move under cover and we move as one'),
Text('Through the night, we have one shot to live another day'),
Text('We cannot let a stray gunshot give us away'),
Text('We will fight up close, seize the moment and stay in it'),
Text('It’s either that or meet the business end of a bayonet'),
Text('The code word is ‘Rochambeau,’ dig me?'),
Text('Rochambeau!', style: DefaultTextStyle.of(context).style.apply(fontSizeFactor: 2.0)),
Text('It’s got a nice ring to it'),
Text('Some of you boys been here before but this time it’s and all-out show of force'),
add_filter( 'wc_session_expiring', 'wc_custom_session_expiring' );
add_filter( 'wc_session_expiration', 'wc_custom_session_expiring' );
function wc_custom_session_expiring( $expiry ) {
return 60 * 60 * 12; // 12 hours in seconds
}
function wc_custom_session_expiring( $expiry ) {
return 60 * 60 * 12; // 12 hours in seconds
}
add_filter( 'wc_session_expiring', 'wc_custom_session_expiring' );
add_filter( 'wc_session_expiration', 'wc_custom_session_expiring' );
fun main(args: Array<String>) {
println("Hello, world!")
}
function empty_cart_after_12_hours() {
if (is_admin()) return;
$current_time = current_time('timestamp');
$cart_time = WC()->session->get( 'cart_time' );
if (empty($cart_time)) {
WC()->session->set( 'cart_time', $current_time );
return;
}
$cart_age_seconds = $current_time - $cart_time;
$cart_expires_seconds = 12 * HOUR_IN_SECONDS;
if ($cart_age_seconds >= $cart_expires_seconds) {
WC()->cart->empty_cart();
}
}
add_action( 'template_redirect', 'empty_cart_after_12_hours', 1 );
<?php
$strings = [
'1234567891011121314151617',
'1234567891011121314151618',
'1234567891011121314151619',
'1234567891011121314151620',
'1234567891011121314151621',
'1234567891011121314151622',
'1234567891011121314151623',
'1234567891011121314151624',
'1234567891011121314151625',
'1234567891011121314151626',
'1234567891011121314151627',
'1234567891011121314151628',
'1234567891011121314151629',
'1234567891011121314151630',
'1234567891011121314151631',
'1234567891011121314151632',
add_filter( 'wc_session_expiring', 'wc_extend_session' );
add_filter( 'wc_session_expiration', 'wc_extend_session' );
function wc_extend_session( $session_time ) {
return 12 * HOUR_IN_SECONDS;
}
function wc_empty_cart() {
if ( ! is_admin() && is_user_logged_in() && ! WC()->cart->is_empty() ) {
$user_id = get_current_user_id();
$cart_updated_timestamp = get_user_meta($user_id, '_woocommerce_persistent_cart_updated', true);
if (empty($cart_updated_timestamp)) {
update_user_meta($user_id, '_woocommerce_persistent_cart_updated', time());
}
else {
$cart_life_span = get_option('woocommerce_cart_persistent_cart_lifespan', (60 * 60 * 24 * 30));
if ( (time() - intval($cart_updated_timestamp)) > $cart_life_span ) {
WC()->cart->empty_cart(true);
update_user_meta($user_id, '_woocommerce_persistent_cart_updated', time());
}
}
}
}
add_action('init
getCurrencyFormatted: (data) {
return PriceTools.getCurrencyFormatted(
data,
model.currencyRate,
currency: model.currency,
)!;
},
//add following code to functions.php
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>
.wp-core-ui .button-primary-disabled, .wp-core-ui .button-primary.disabled {
opacity: 1;
}
</style>';
}
async fn fetch_user_data(url: String) -> Result<Vec<UserData>, String> {
let mut response = reqwest::get(&url).await.map_err(|e| e.to_string())?;
if !response.status().is_success() {
return Err(response.status().to_string());
}
let body = response.text().await?;
let results: Vec<UserData> = serde_json::from_str(&body)?;
Ok(results)
}
<Label Text="{Binding Title, StringFormat='{0:N2}'}"/>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <ctime>
#include <complex>
using namespace std;
typedef double lf;
typedef complex<lf> pt;
typedef long long ll;
const lf PI = acos(-1.0);
const ll INF = 1e18;
ll mul(ll a, ll b){
if (a == 0) {
return 0;
}
if (a == 1) {
return b;
}
if (b <= LLONG_MAX / a) {
return a * b
function remove_product_from_cart() {
global $woocommerce;
foreach($woocommerce->cart->get_cart() as $cart_item_key => $cart_values) {
// get the product id
$product_id = $cart_values['product_id'];
// get the variation id if it exists
$variation_id = ( isset( $cart_values['variation_id'] ) ) ? $cart_values['variation_id'] : '';
// get the product quantity
$quantity = $cart_values['quantity'];
// remove the product from the cart
$woocommerce->cart->remove_cart_item($cart_item_key);
}
}
add_action( 'woocommerce_before_cart_item_quantity_zero', 'remove_product_from_cart' );
SS
overflow-x: hidden;
overflow-y: scroll;
// Add your code here
add_filter( 'wcfmmp_store_title', 'wcfmmp_store_title_filter', 10, 2 );
function wcfmmp_store_title_filter( $store_title, $vendor_id ) {
$store_info = wcfmmp_get_store( $vendor_id );
if( !$store_info ) return $store_title;
return $store_title . ' - ' . $store_info['store_name'];
}
Generate
More than just a code generator. A tool that helps you with a wide range of tasks. All in one place.
Function from Description
Text Description to SQL Command
Translate Languages
Generate HTML from Description
Code to Explanation
Fix invalid Code
Get Test for Code
Class from Description
Regex from Description
Regex to Explanation
Git Command from Description
Linux Command
Function from Docstring
Add typing to code
Get Language from Code
Time complexity
CSS from Description
Meta Tags from Description