Find Jobs
Hire Freelancers

WooCommerce

€8-30 EUR

In Progress
Posted over 9 years ago

€8-30 EUR

Paid on delivery
I have a WordPress website using Woocommerce. I need to attach images to products automatically when uploaded through the Add Media. At the moment I have the following code: add_action('add_attachment', function( $attachmentID ) { if ( ! class_exists( 'WC_Product' ) ) return; // if no WooCommerce do nothing // an attachment was jus saved, first of all get the file name $src = wp_get_attachment_image_src( $attachmentID, 'full' ); $filename = pathinfo( $src[0], PATHINFO_FILENAME ); // now let's see if exits a product with the sku that match filename $args = array( 'meta_key' => '_sku', 'meta_value' => $filename, 'post_type' => 'product', 'posts_per_page' => '1' // assuming sku is unique get only one post ); $prods = get_posts( $args ); if ( ! empty($prods) ) { // ok we have a match, exists a product having sku that match filename $product = array_pop( $prods ); // set the thumbnail for the product set_post_thumbnail( $product, $attachmentID ); // now "attach" the post to the product setting 'post_parent' $attachment = get_post( $attachmentID ); $attachment->post_parent = $product->ID; wp_update_post( $attachment ); } }); It takes the name of the image and automatically attaches to the product with the matching SKU. For example [login to view URL] becomes automatically the Main Product Image of the product having the SKU set as 45rt10. The problem is that is only working with products who are set as Simple Product. Variations (each having a unique SKU) is not having the images attached. I need someone to start today.
Project ID: 6634971

About the project

5 proposals
Remote project
Active 10 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Hi there, I have expertise in woocommerce as well as wordpress give me chance to solve your eroor .. we read your project carefully and willing to serve you with our best [login to view URL] offer cutting-edge web design and developing services with the most relevant current technologies like CSS, HTML, Jquery, etc. With a cost- and time-effective approach, we cover all areas of project execution from design to delivery, guaranteeing maximum clients’ satisfaction. Executed contracts may be reviewed at the clients’ request at minimal costs in order to furnish an improved and sophisticated job delivery. Your interests are our concern, and your satisfaction is always guaranteed. thanks
€29 EUR in 1 day
0.0 (0 reviews)
0.0
0.0
5 freelancers are bidding on average €35 EUR for this job
User Avatar
Hello! I have a lot of experience in Debug/solve issues with WP and WooCommerce. Can debug this code for you and add needed modifications to allow same things for variable products.
€55 EUR in 1 day
4.9 (387 reviews)
7.5
7.5
User Avatar
A proposal has not yet been provided
€24 EUR in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
Hi Dear, Your challenging project caught our attention and our expert team are ready to start work on your project ..We create web-based and online-driven design solutions with the most relevant and extant IT technologies at a most competitive price. We prioritize client satisfaction from project start up to delivery with a notable pride in our industry-acclaimed proficiency, all with our youthful team of specialists. We are able to construct, review, and present client-specific websites with multi-functionalities geared towards enhancing personal and commercial business profiles. Thanks
€34 EUR in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of MALTA
Marsa, Malta
5.0
8
Member since Nov 16, 2013

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.