How can I hide/display add to cart button from Shopify product pages using Shopify app in Laravel or Node? - shopify-app

I am writing an app and I want to make a switch button to hide/display 'Add to Cart' button by using this app. How can I write code and implement this in Liquid.

Assuming you are using PHP (Laravel) as the backend for your Shopify App you could use the "phpclassic/php-shopify" library and call the "ScriptTag" method to load an external Javascript file into a store's front-end. The JavaScript file would have to manipulate the DOM to hide/display the Add to Cart button.
Code to hide any add-to-cart buttons might look like:
Array.from(document.querySelectorAll('button.add-to-cart')).map(el=>el.style.display='none');
If you wanted to conditionally hide buttons for specific products, then the JavaScript file would need to talk to your App back-end to obtain that information.
Note that this does not involve Liquid at all. Liquid is the theme template laguage Shopify uses. Programmatically modifying the theme's liquid files is a more difficult approach and liquid files you've added via an App get left behind if your App is uninstalled.

Related

Display alt product/json data via shopify app proxy in existing shopify product theme

I want to display a modified version of a product page - for example, something as simple as not displaying the buy button, based on an external validation/check. theoretically, it's not that complicated, but I'm stuck.
Here is what I know/see/understand.
In liquid code, there is
templates -> product.json
sections -> main-product.liquid
I created
templates -> product.alternate.json (a duplicate of product.json minus the buy button)
snippets -> alternate-product.liquid (which is just content_for_layout)
changes in template.liquid to handle the a product template
If I change the product template to alternate - my snippet correctly loads and the alternate product without the buy button is displayed correct.
I change alternate-product.liquid to do an ajax call to to get app proxy.
On app proxy I've tried
returning the same data as product.json, liquid content type this didn't show anything in the body (header and footer are there)
using the site access token to fetch a hardcoded product by id and returning this json (content-type json), same, it's just header and footer.
What I'm trying to do is use a $.get('/apps/s/serve/some-unique-id') that will render the correct json/liquid that shows or doesn't show, the buy now button "some-unique-id" is a client side id.
I know we can manually create the needed HTML tags server side and send them - but this doesn't use the theme/style that's already applied for the rest of the shopify site.

How to create a Pop up box on laravel

I want to create a popup box which will be load after website full loading. I want show some notice or advertisement to user by this pop up box which will be auto appear after web loading. So how do i do this?
This is majorly a frontend task. So, Id do it in the following way:
Use laravel to render the page i want to display the popup
On the blade view of the page I will use html, css and javascript to structure, style and show the pop up when the page loads.
This link might provide you more information: https://websolutionstuff.com/post/how-to-add-bootstrap-modal-in-laravel?ref=morioh.com&utm_source=morioh.com

Oxid eShop event handlers

I am trying to create some tracking events on OXID eShop Framework on a custom module but I can't find any event handlers or something to put the code on some custom pages, without editing the core files. What I want is to make some custom API calls if I am on product page, category page, basket, etc.
Is there any way I can handle this in a custom module?
OXID has no such events or hooks you might know from magento or shopware. You have two options:
1) For running server side php code you need to extend OXID's functions, e.g. render() function for the pages you want to track.
For the product page it would be "details" -> applications/controllers/details.php
category page is "alist.php" and basket is basket.php
2) Make client side api calls with simple JS. You could appent all your js code to a tempalte block (e.g. in header oder footer) and create some if-else logic for different controller classes.
Like here: https://github.com/OXID-eSales/oxideshop_ce/blob/b-5.3-ce/source/application/views/azure/tpl/layout/base.tpl#L32
You could also have a look at any tracking module for google analytics or piwik, they are pretty similar to what you want to do.
I can give you more examples if you want.

Wordpress custom menu using Ajax

I am creating a website that has a huge number of forms that are called from a dynamically created menu. There may be a number of other pages on the site that are basic HTML layouts. I was thinking to use Wordpress as the controller for my site. That way I do not have to replicate the Wordpress layout features. I would need to do the following:
Have Wordpress get the contents of the menu using AJAX which would
return the descriptions and the links to the pages.
On selection of an option from the menu open the page in an iframe.
Is this even possible and, if so, where would I start?

add Widgets from Backend without editing XML

Is there any possibility in Magento to add a "widget" to the sidebar, using the backend only – without editing XML. I'd like to provide that function to a customer, who may add blocks/widgets to the sidebar similar like how it's possible using Wordpress.
Or did I have a false concept in mind of what widgets are in Magento?
You can add widget to any static page/block. See this tutorial: http://www.siteground.com/tutorials/magento/magento_widgets.htm

Resources