Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #558558

    Hi,
    I’m using Enfold with woocommerce. I’m styling all my product pages with advanced layout builder and I do some custom changes by adding php codes (using the insert php plugin).

    One of the sections I wanted to display the product thumbnail image and I used the code:

    [insert_php] the_post_thumbnail( array(256, 256)); [/insert_php]

    and it works.

    But in another section, I just want to display the first image of the woocommerce’s product gallery individually. (Actually, there will be only one image on the product gallery.)
    What should be the php code for this?

    Thanks for your help.

    #558559

    Hi fantasthink!

    Try something like that, and let usk now if it works

    <?php 
    $attachment_id = 8; // attachment ID
    
    $image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array
    if( $image_attributes ) {
    ?> 
    <img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>">
    <?php } ?>

    I guess you do understand the code, as you doing such advanced customization of the product page!

    Cheers!
    Basilis

    #558701

    Well actually I’m not good at coding that much. Just a bit brave to play with things to achieve my goals.

    In this case, what I’m trying to achieve is to create a product page template using your advanced layout editor. I want to create a box in this template that shows the actual products logo image, name, price, purchase button and a note about the purchase process. I know I can do this manually for each product. But I want to automate things to eliminate human error.

    So far I achieved this with php codes in text blocks:

    [insert_php] the_post_thumbnail( array(256, 256)); [/insert_php] –> displays the featured image on top.
    [insert_php] the_title(); [/insert_php] –> displays the product name
    $ [insert_php] $bcprice = get_post_meta( get_the_ID(), ‘_regular_price’, true ); echo esc_html( $bcprice ); [/insert_php] –> gets the product price and displays in h1 tag.

    And I use product purchase button element below them.

    These all takes the data from database. So when I load this box as a template from the advanced layout editor I do not need to change any value manually.

    My problem is the image as I told. I want to seperate the featured image and product logo image. So in the shop page I want to see the featured img. But in the product page I need to see the logo image in this purchase box I created. I thought the easiest way to get this to add the product logo img as the first product gallery image and call this with a php code to display in the purchase box.

    I tried the code you gave me. But it needs a defined ID at the beginning so this will not be automated. What I need is to call the ID of the first gallery image from database and display it.

    I don’t know that much coding. And I’m not sure if this is an advanced customization request. All I need is a little help only with this code.

    Thanks so much.

    #558873

    Hey!

    Everything is possible, but that would need a lot of work to be done.

    You can contact one of our Customization Contractors, who will help you out with the process.
    http://kriesi.at/contact/customization

    Let us know if we could do anything else, regarding our theme

    Regards,
    Basilis

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.