I have created a new field using ACF for woocommerce. The field is called "position" and has default value 52.
Now I want this value as a php variable in a image generation script.
Inside one function I have:
$position = get_field('position');
and
echo '<input type="hidden" name="position2" value="'.$position.'" id="position2" >';
At frontend I see that field "position2" is filled with the product field value 52. So that works!
In a different function in the same php file, I am trying to reuse this variable, and I can't get it to work. I need $position to represent '52' in below code.
function _create_image( $ax1, $ax2, $ax3 ) {
...
imagecopy($template, $sky, 148, $position, 0, 0, 660, 660);
...
}
If I do this, $position is an empty value in this function. I have tried global, and 'use $position', but I can't seem to get it working.