Plugin Author
WP24
(@wp24dotorg)
The domain name is stored within the cart item. So you would have to loop through the cart items and find the corresponding product to get the domain name.
Something like this (content-single-product.php):
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
if ( $cart_item['product_id'] == get_the_ID() )
echo $cart_item['wp24_domain'];
}
Hello, unfortunately I didn’t received an answer to my question. Maybe my question was not clear enough, this is why I wiill try to explain it again.
step 1. the user will use the search bar of the pluginn to see if the desired domain is available.
step 2. the available domains wil be displayed by the pluggin with the price and the button “buy now for $10”
step 3. the user will chose the desired available TLD and will click on the button, but it will not add the domain to cart in this step, actually it will redirect the user to the woocommerce product page where the user must fill-up some additional informations.
step 4. then the user will click the “Add to cart” button on the woocommerce product page.
Now my question is for step 3 when the user will be redirected to the product page:
Is it possible to take the selected domain somehow in a global variable which will be then used into the custom function to display this domain as a shortcode? My function is in the previous message.
-
This reply was modified 2 years, 5 months ago by
petrumuntiu.
-
This reply was modified 2 years, 5 months ago by
petrumuntiu.
-
This reply was modified 2 years, 5 months ago by
petrumuntiu.
Plugin Author
WP24
(@wp24dotorg)
I’am afraid that this would not work with the WooCommerce integration of the plugin.
An idea could be to use the Prices & Links and create a custom page to which you pass the domain and then store it in a global variable. For example https://yourdomain.com/savedomain.php?domain=\[domain\].\[tld\]. Inside the savedomain.php you read the domainname from the URL and save it into a global variable. Then you redirect to the product page.
Hello, It worked and now I am able to use the domain and tld as variables.
I have used the URL attributes. First I created my custom link by using the Hook from your plugin
function change_whois_result( $whois_result ) {
if ( in_array( $whois_result['tld'], array( 'net','ro','eu','com','us','org','info','biz','es','de','uk','co.uk','in' ) ) ) {
$whois_result['link'] = 'https://truesoft-d.com/product/domain-[tld]/?domain=[domain]&tld=[tld]';
}
return $whois_result;
}
Then I have created an additionl fuction to store the variables
function add_get_val() {
global $wp;
$wp->add_query_var('domain');
$wp->add_query_var('tld');
}
add_action('init','add_get_val');
And then I have used a shortcode fuction to read the values
function WhoisDomainShortcode() {
return get_query_var('domain') .'.' . get_query_var('tld');
}
add_shortcode('wp24_result_domain', 'WhoisDomainShortcode');
Many thanks for your advice.