Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 12-11-2023, 03:29 PM   #1
CaligulaDrusilla
Confirmed User
 
Industry Role:
Join Date: Oct 2023
Posts: 63
Plugin for woocommerce that changes product title after purchase

Does anyone here know if that exists?
CaligulaDrusilla is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-03-2024, 09:08 AM   #2
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,220
what do you want to do to the title?

you will have to use the action, which contains the order id, and you will have to get all the product ids in that order in the callback function, and update the post object and have it save.

im unsure on what you want to do with the title, so i cant really give an example before knowing the use case.


is the action to use

woocommerce_order_status_completed

this is untested, but its a start to get where you want to go.

dont use on a live site. if you have a demo playground enable WP_DEBUG in wp-config.php incase you have any errors.

Code:
<?php

add_action('woocommerce_order_status_completed', 'change_title_on_competed_status' 10, 1);

function change_title_on_competed_status( $order_id ) {

    $order = wc_get_order( $order_id );

    foreach ( $order->get_items() as $item_id => $product_item ) {
        $product_id = $product_item->get_product_id();
        $product_title = $product_item->get_name();
        $args = array('ID' => $product_id, 'post_title' => $product_title . ' add text on to end if you want?');
        wp_update_post( $args );
    }
}
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
purchase, exists, woocommerce, product, title, plugin
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.