(WordPress/WooCommerce) Add custom product field and download link to be used manually via PHP

취소 완료 등록 시간: 7년 전 착불
취소 완료 착불

Hello,

I have a WordPress website that runs WooCommerce and sells shipping labels.

Each shipping label is unique. Every time the customer wishes to buy a label, a new product is generated in WooCommerce via PHP. The item is marked as 'virtual' and 'downloadable', so that the user can download their file (shipping label) once the purchase is made. I'm able to generate new items without any problems, however I'm having trouble passing the shipment information through.

I need to be able to pass an extra variable, called "shipment_id", that gets created at the same time as the item gets generated during shopping. The variable needs to get attached to the item. I need to retrieve that variable once payment is confirmed on the "Order Received / Thank You" page , so that I can use some PHP code to retrieve the appropriate label for each item.

Once the label is retrieved, I need to be able to update the download link for each item.

------------------------------

Short Description:

1. Show examples on how to add and retrieve a custom WooCommerce product field via PHP (let's call it shipment_id).

2. Create code to be able to set and retrieve a WooCommerce product download link

These are probably the templates that you'll need to modify:

[url removed, login to view]

[url removed, login to view]

[url removed, login to view]

(probably others?)

Here's the sample code that creates a unique item via PHP:

$my_post = array(

'post_title' => 'USPS Priority Mail or Fedex or something',

'post_content' => 'Description of the item goes here',

'post_status' => 'publish',

'post_author' => 1,

'post_type' =>'product'

);

// Insert the post into the database

$product_ID = wp_insert_post( $my_post );

if ( $product_ID ){

// Basic product info

add_post_meta($product_ID, '_regular_price', $rate->rate );

add_post_meta($product_ID, '_price', $rate->rate );

add_post_meta($product_ID, '_stock_status', 'instock' );

// Only allow one copy of each unique shipping label per cart

add_post_meta($product_ID, '_sold_individually', 'yes' );

// Make product downloadable

add_post_meta($product_ID, '_virtual', 'yes' );

add_post_meta($product_ID, '_downloadable', 'yes' );

// Set temporary product download url

(Your code goes here)

I've tried this code but it doesn't seem to work:

add_post_meta($product_ID, '_wc_file_names', 'Download Link' );

add_post_meta($product_ID, '_wc_file_urls[]', '[url removed, login to view]' );

add_post_meta($product_ID, '_download_expiry', 7 );

I'm looking for someone who can complete this project within the next 24 hours. Full payment upon completion and code tested and verified. Add "Postage123" in the beginning of your bid to let me know you've read the project, understand it, and can complete it.

PHP 워드프레스

프로젝트 ID: #10841353

프로젝트 소개

18 건(제안서) 재택 근무형 프로젝트 서비스 이용 중: 7년 전

이 일자리에 대한 프리랜서 18 명의 평균 입찰가: $58

toinnisfree

I have read your project details, and I am interested in offering my services. I provide 100% satisfaction guaranteed on all my work. Milestone is required to begin; to be released when the job has been satisfactor 기타

$75 USD (1일 이내)
(749 리뷰)
8.3
evgendob

Hello. Wordpress dev expert ready to help you with woo functionality creation. I have more 200 good reviews in dev projects, so all will be done on highest level. Price can be discussed. Please, do not award project 기타

$45 USD (1일 이내)
(381 리뷰)
7.7
yogeshssanwal

Hi there - My name is Dimple. I’ve read your brief and can see that you’d like to build an Website. My team has 4 years experience designing and developing mobile apps and Websites as well as SEO.I would approach your 기타

$88 USD (3일 이내)
(69 리뷰)
5.3
nileshbakotiya

you will find my services highly reliable and professional. My Vision : High Quality, High Speed, High Satisfaction! i have 7 years business experience with certified and skilled . We are always looking to push fo 기타

$20 USD (1일 이내)
(11 리뷰)
2.9
salesankit90

Hello, I have been doing website designing and developing from last 5+ years and such jobs are my daily practice. This is my first time on this site and hence you can see that I don't have any ratings/testimonials t 기타

$111 USD (3일 이내)
(1 리뷰)
1.4
hanifkhan09

Dear client I am highly interested to do this project. I will make you happy.I don’t need any upfront or milestone payment. Pay me when you will happy. Looking forward. Thanks

$25 USD (1일 이내)
(0 리뷰)
0.0
amberoo6

I am 7 years expert in the relevent field.I understand your requirements so I offer you my services with quality work and will fully satisfy you. feel free to contact Thank you

$17 USD (4일 이내)
(0 리뷰)
0.0