PHP implode query - why is this wrong?
Posted: Thu Jan 25, 2018 7:24 am
Hi there.
We are getting errors on the implode code.
Is the current version of PHP using this differently now??
Error is PHP Warning: implode(): Invalid arguments passed.
We are getting errors on the implode code.
Is the current version of PHP using this differently now??
Error is PHP Warning: implode(): Invalid arguments passed.
Code: Select all
add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_echo_stock_variations_loop' );
function bbloomer_echo_stock_variations_loop(){
global $product;
if ($product->get_type() == 'variable') {
foreach ($product->get_available_variations() as $key) {
$attr_string = '';
foreach ( $key['attributes'] as $attr_name => $attr_value) {
$attr_string[] = $attr_value;
}
if ( $key['max_qty'] > 0 ) { echo '' . implode(', ', $attr_string) . ': ' . $key['max_qty'] .' in stock<br/>'; } else { echo '' . implode(', ', $attr_string) . ': out of stock<br/>'; }
}
}
}