Open file from parent document

Home Forums Puzzles Open file from parent document

This topic contains 11 replies, has 2 voices, and was last updated by Yuri Kovelenov Yuri Kovelenov 1 week, 1 day ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #18410
    Avatar
    hoody
    Newbie

    Hey guys Im using the “open file” puzzle to replace a texture on an object.

    Is there a way to use another file uploader in the parent document to replace the texture.

    I´ve got a basic file uploader from wordpress on a woocommere product page and want the user to be able to use this uploader (located in parent document) to change the texture on the object.

    Thanks

    #18411
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

    Hi,

    You can use an HTML event puzzle with your parent doc (for example, to setup clicks on a div). Inside its do slot just use the open file puzzle. It should work!

    3D Verger, the CEO
    LinkedIn | FB | Twitter | VK | 新浪微博

    #18414
    Avatar
    hoody
    Newbie

    yes thanks for your answer. i understand but thats not what im trying to achive.

    I need the image to be fetched from the original wp uploader (located in parent document on a Woocommerce Product page) – because the image is also used for the woocommerce checkout after clicking the add to cart button.

    If I use your uploader there will be no connection to woocommerce, when clicking add to cart.

    do you get what i mean?

    #18416
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

    So the image already exists and you just need to fetch it? By URL or something?

    3D Verger, the CEO
    LinkedIn | FB | Twitter | VK | 新浪微博

    #18476
    Avatar
    hoody
    Newbie

    Im not sure about that, if it actually exists. Basicly what you suggested first was “triggering” the “open file puzzle” from verge by clicking on an element in the parent document.

    But what I need is: triggering an uploader (not the one from verge) that comes from woocommerce and is located in the parent document. Basically its the same file-upload like the one frome verge, but its provided by the woocommerce product itself.

    So what i need is a puzzle or a piece of code that can get the image from an “external” (aor any) uploader located in the parent document. Is there a way to detect if any image was uploaded , not only through the open file puzzle?

    I attached a screenshot for better understanding and also heres the link: http://brudastan.de/produkt/jajaja

    I need to use the file upload from woocommerce, or the image will not be saved wo Cart or checkout page.

    I hope you can now better understand what i meant.

    Greets

    Attachments:
    You must be logged in to view attached files.
    #18478
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

    Thanks for the details, now I see what you want.

    The open file puzzle creates an input element, “clicks” on it, waits until the image is loaded and then saves the loaded image data to a global variable. You can check the generated code in the visual_logic.js file. It looks like this:

    So, instead of that temporary input element, you need to use an existing one provided by Woocommerce. To do that, replace

    var input = document.createElement('input');

    with

    var input = parent.document.getElementsByClassName('wc-pao-addon-file-upload input-text wc-pao-addon-field');

    and remove other lines related to input creation and deletion so that it looks like

    The changes in visual_logic.js will be dropped once you save Puzzles again, but at least give this a try.

    3D Verger, the CEO
    LinkedIn | FB | Twitter | VK | 新浪微博

    #18480
    Avatar
    hoody
    Newbie

    Thank you for your answer! When I try your code , i get an error in my console.

    v3d.js:1 TypeError: input.addEventListener is not a function (its reffering to line 8 in your code)

    Attachments:
    You must be logged in to view attached files.
    #18482
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

    May be the rest of the document has not loaded yet. Try calling open file upon mouse click or something.

    3D Verger, the CEO
    LinkedIn | FB | Twitter | VK | 新浪微博

    #18496
    Avatar
    hoody
    Newbie

    Hi Thanks. now the error is gone, but the fuction is not executed.

    maybe you could take a look at my code (click event):

    eventHTMLElem(‘click’, ‘wc-pao-addon-file-upload input-text wc-pao-addon-field’, true, function(event) {
    console.log(“trigger”)
    openFile(function() {
    replaceTexture(‘vladmaterial’, ‘vlad.jpg’, _pGlob.openedFile, function() {});
    });
    });

    #18517
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

    Hi,

    This won’t work with class name. Try creating your own button or use a timer puzzle.

    3D Verger, the CEO
    LinkedIn | FB | Twitter | VK | 新浪微博

    #18542
    Avatar
    hoody
    Newbie

    I seem to have fixed it! Thank you very much for your kind support!

    • This reply was modified 1 week, 1 day ago by Avatar hoody.
    #18544
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

    Excellent! :good:

    3D Verger, the CEO
    LinkedIn | FB | Twitter | VK | 新浪微博

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.