Last active
December 4, 2023 11:38
-
-
Save ihslimn/82954bcd3ee627e94755d89940735f74 to your computer and use it in GitHub Desktop.
wc-cross-sells-macro.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'jet-engine/register-macros', function(){ | |
if ( ! function_exists( 'WC' ) ) { | |
return; | |
} | |
class WC_Cross_Sale_Macro extends \Jet_Engine_Base_Macros { | |
public function macros_tag() { | |
return 'wc_cross_sales'; | |
} | |
public function macros_name() { | |
return 'WC Cart Cross Sales'; | |
} | |
public function macros_args() { | |
return array(); | |
} | |
public function macros_callback( $args = array() ) { | |
if ( ! WC()->cart ) { | |
return PHP_INT_MAX; | |
} | |
$cross_sells = WC()->cart->get_cross_sells(); | |
$result = implode( ',', $cross_sells ); | |
if ( empty( $cross_sells ) ) { | |
$result = PHP_INT_MAX; | |
} | |
return $result; | |
} | |
} | |
new WC_Cross_Sale_Macro(); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, but Crocoblock support advised me to display cross sells via Linsting Grids in product sheets. The goal is to be able to use a custom loop, which is not possible with the cross sell widget from jetwoobuilder.
It is in any case an enigment, logged in it appears, not logged in it disappears...