'rand', 'limit' => 1, 'status' => 'publish' )); if (!empty($random_product) && has_post_thumbnail($random_product[0]->get_id())) { $product_id = $random_product[0]->get_id(); $parent_id = $random_product[0]->get_parent_id(); $image = wp_get_attachment_url($random_product[0]->get_image_id()); $product_url = get_permalink($product_id); $name = $random_product[0]->get_name(); } else { // Static data as fallback $product_id = '1234'; $parent_id = '2342'; $image = AMBISN_URL.'assets/images/no_image.png'; $product_url = '#'; $name = 'Product Name'; } }else{ if(isset($product_id)){ $product = wc_get_product( $product_id ); $parent_id = $product->get_parent_id(); if($parent_id == '0'){ $image = wp_get_attachment_url( $product->get_image_id()); $product_url = $product->get_permalink(); $name = $product->get_title(); } else{ $variation = wc_get_product($product_id); $product_url = $variation->get_permalink(); $name = $variation->get_name(); $product_id.= ' -variation-'; $image = wp_get_attachment_url( $variation->get_image_id()); } }else{ return; } } $theme_color = ambisn_get_setting('email_theme_color'); if(empty($theme_color)){ $theme_color = '#333333'; } $logo = ambisn_get_setting('store_logo'); if(empty($logo)){ $logo = esc_url( wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' )[0] ); if(empty($logo)){ $logo = AMBISN_URL.'assets/images/wp-logo.png'; } } ?>
|