Skip to content

Instantly share code, notes, and snippets.

@ihslimn
Last active December 4, 2023 11:38
Show Gist options
  • Save ihslimn/82954bcd3ee627e94755d89940735f74 to your computer and use it in GitHub Desktop.
Save ihslimn/82954bcd3ee627e94755d89940735f74 to your computer and use it in GitHub Desktop.
wc-cross-sells-macro.php
<?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();
} );
@Goodigital-Agency
Copy link

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment