th - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of th.php
- <?php
- $brand_terms = get_the_terms( $product->id, 'pa_brand' );
- if ( $brand_terms && ! is_wp_error( $brand_terms ) ) {
- $brand_slug = $brand_terms[0]->slug;
- if ( $brand_slug ) {
- $formatted_brand = str_replace( '-', '-/-', ucwords( $brand_slug ) );
- $formatted_brand = str_replace( 'kia', 'KIA', $formatted_brand );
- $partnumber_values = get_the_terms( $product->id, 'pa_partnumber' );
- foreach ( $partnumber_values as $partnumber_value ) {
- $archive_link = get_term_link( $partnumber_value->slug, 'pa_partnumber' );
- $image_url = 'https://partsouq.com/assets/PartCoverThumbnail/' . $formatted_brand . '/' . $partnumber_value->name . '-COVER.png';
- echo '<img src="' . $image_url . '" alt="' . $partnumber_value->name . '">';
- }
- }
- }
- ?>